fix(api): define missing ApiErrorCodes constants used by error_response#146
Open
agbid wants to merge 1 commit into
Open
fix(api): define missing ApiErrorCodes constants used by error_response#146agbid wants to merge 1 commit into
agbid wants to merge 1 commit into
Conversation
12 error codes referenced via ApiErrorCodes::XXX across controllers (pipeline_items, contacts, pipelines, labels, teams, macros, automation_rules, custom_filters, notifications, custom_attribute definitions, dashboard_apps, webhooks, agent_bots, inboxes, etc.) were never defined as constants, so evaluating ApiErrorCodes::XXX raised NameError before error_response could run — turning intended 404/409/422 responses into HTTP 500s. Also add status: :not_found to the two pipeline_items_controller "not found" responses to match sibling controllers.
Reviewer's GuideDefines previously-missing ApiErrorCodes constants used across controllers and aligns pipeline_items not-found responses with existing patterns so they return 404s instead of 500s. Sequence diagram for pipeline_items create with missing conversation/contactsequenceDiagram
actor Client
participant PipelineItemsController
Client->>PipelineItemsController: create
PipelineItemsController->>PipelineItemsController: [conversation is nil]
PipelineItemsController->>PipelineItemsController: error_response(ApiErrorCodes::CONVERSATION_NOT_FOUND, message, status: :not_found)
PipelineItemsController-->>Client: 404 CONVERSATION_NOT_FOUND
Client->>PipelineItemsController: create
PipelineItemsController->>PipelineItemsController: [contact is nil]
PipelineItemsController->>PipelineItemsController: error_response(ApiErrorCodes::CONTACT_NOT_FOUND, message, status: :not_found)
PipelineItemsController-->>Client: 404 CONTACT_NOT_FOUND
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ApiErrorCodes::XXXacross 11+ controllers (pipeline_items,contacts,pipelines,labels,teams,macros,automation_rules,custom_filters,notifications,custom_attribute_definitions,dashboard_apps,webhooks,agent_bots,inboxes,pipeline_tasks, integration hooks) were used but never defined as constants inApiErrorCodes.ApiErrorCodes::XXXfor an undefined constant raisesNameErrorbeforeerror_responseeven runs, turning what should be a clean 404/405/409/422 into an HTTP 500INTERNAL_ERROR.pipeline_manipulationtool:add_to_pipeline(POST/pipelines/:id/pipeline_items) crashed withNameError - uninitialized constant ApiErrorCodes::CONVERSATION_NOT_FOUNDwhenever the lookup conversation wasn't found.CONTACT_NOT_FOUND,CONVERSATION_NOT_FOUND,TEAM_NOT_FOUND,LABEL_NOT_FOUND,AUTOMATION_RULE_NOT_FOUND,MACRO_NOT_FOUND,CUSTOM_FILTER_NOT_FOUND,NOTIFICATION_NOT_FOUND,CUSTOM_ATTRIBUTE_NOT_FOUND,METHOD_NOT_ALLOWED,CANNOT_DELETE_RESOURCE,OPERATION_FAILED) toapp/models/concerns/api_error_codes.rb.status: :not_foundto the twopipeline_items_controller.rb"not found" responses (conversation/contact), matching the pattern used by every other*_NOT_FOUNDresponse in the codebase.Test plan
ruby -csyntax check on both changed filesPOST /api/v1/pipelines/:id/pipeline_itemswith a non-existentitem_idnow returns404 CONVERSATION_NOT_FOUND/404 CONTACT_NOT_FOUNDinstead of500 INTERNAL_ERRORPATCH /api/v1/pipelines/:id/pipeline_items/:id/move_to_stagefailure path (OPERATION_FAILED) returns422instead of500🤖 Generated with Claude Code
Summary by Sourcery
Define missing API error codes and ensure pipeline item not-found errors return 404 instead of 500.
Bug Fixes: