Skip to content

Conversation

@eiresendez
Copy link
Contributor

@eiresendez eiresendez commented Feb 12, 2025

Issue & Reproduction Steps

Previously, when a process was not found in the api/1.0/processes/{process}/, the app automatically threw a ModelNotFoundException, which was handled globally by the Handler.php. However this approach led to the API response being redirected to the fallback route, returning a generic “Not Found” message instead of a more specific error.

  1. Make a GET request to /api/processes/{invalid_id} with a non-existent processId.
  2. The API returns a 404 error with a generic fallback message instead of a specific response.

Solution

  • Removed route model binding (Process $process) in the show() method.
  • Now using Process::find($processId), which returns null instead of throwing an exception.
    • If the process is not found, the API responds with a custom JSON message:
  • This prevents the exception from being caught by the global Handler.php, ensuring the correct error response is returned.

Screenshot 2025-02-12 at 09-48-41 Edit Process - ProcessMaker

How to Test

Follow the reproduction steps from JIRA ticket.

Expected behavior: The API now returns a clear and consistent error message without relying on the exception handler.

Related Tickets & Packages

.

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

…n handler

- Now, the process lookup is done with Process::find($processId) instead of route model binding.
- Returns a JSON response with a custom error message when the process is not found.
- Prevents fallback redirection and ensures a predictable API response.
- Maintains API consistency
@eiresendez
Copy link
Contributor Author

NOTE: The failing tests are not related to the changes in the PR. The issue has already been reported here: https://processmaker.atlassian.net/browse/FOUR-21949

@processmaker-sonarqube
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@ryancooley ryancooley merged commit ce2beec into release-2025-winter Feb 26, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants