Fix spec issues from merged PRs #405 and #406#416
Open
salmanbshah wants to merge 1 commit intomainfrom
Open
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Why?
PRs #405 and #406 documented two new endpoints in the Unstable spec but introduced several discrepancies between the spec and actual backend behavior. An audit identified 5 issues — wrong error formats, missing enums, incorrect error codes, and undocumented auth requirements.
How?
Five targeted fixes to
descriptions/0/api.intercom.io.yaml, each verified against backend source code.Decisions
Kept all fixes in a single PR since they're all corrections to the same spec file from the same audit pass.
Backend evidence for each fix
Fix 1: 400 error format on GET /messages/whatsapp/status
Was: flat
{type: error, request_id, message}— Should be:{type: "error.list", errors: [{code, message}]}Backend proof: All
ApiCodedErrorexceptions go througherror_handler.rb→render_error→render_errors, which always wraps in theerror.listformat. The 404 example in the same endpoint already used the correct format — this was an inconsistency within the same PR.Fix 2:
typeenum missing on whatsapp_message_statusWas: no enum, just
example: broadcast_outbound— Should be: 5 valuesBackend proof:
whatsapp_event.rb:14-19defines the enum:Fix 3: required properties on whatsapp_message_status
Was: no
requiredarray — Should be:[conversation_id, status, type, message_id]Backend proof:
messages_controller.rbwhatsapp_statusaction always builds the response hash withconversation_id,status,type, andmessage_idfrom non-nullable DB columns.Fix 4: 401 error code on PUT conversation_parts
Was:
code: unauthorized,message: Access Token Invalid— Should be:code: token_unauthorized,message: Not authorized to access resourceBackend proof:
code.rb:44definesTOKEN_UNAUTHORIZED = 'token_unauthorized'. The controller'sunauthorized_api_errormethod returnsmessage: 'Not authorized to access resource'.Fix 5: WRITE_TICKETS scope undocumented on PUT conversation_parts
Was: no mention of ticket scope — Should be: documented
Backend proof:
conversation_parts_controller.rb:58-61checksunauthorized_ticket_write?which verifies@token.scope.include?(WRITE_TICKETS)for ticket conversations.Implementation Plan
Fix PRs #405 and #406 — OpenAPI Spec Issues
Context
PRs #405 and #406 documented two previously-undocumented endpoints in the Unstable spec. Both merged. An audit found multiple discrepancies between spec and backend. Single PR to fix all 5 issues.
File to modify
descriptions/0/api.intercom.io.yaml— only fileFixes
From PR #405 — GET /messages/whatsapp/status
Fix 1 (HIGH): 400 error example — wrong format
Spec has flat
{type: error, request_id, message}. Backend always renders{type: "error.list", errors: [{code, message}]}viaerror_handler.rb→render_errors. The 404 in the same endpoint is already correct.Fix 2 (HIGH): type field missing enum
whatsapp_event.rb:14-19defines 5 values. Spec has none.Fix 3 (MEDIUM): No required properties
Controller always returns
conversation_id,status,type,message_id.From PR #406 — PUT /conversations/{conversation_id}/conversation_parts/{id}
Fix 4 (HIGH): 401 error code and message wrong
Spec:
code: unauthorized,message: Access Token InvalidBackend:
code: token_unauthorized,message: Not authorized to access resourceFix 5 (MEDIUM): WRITE_TICKETS scope undocumented
Controller checks
unauthorized_ticket_write?verifying WRITE_TICKETS scope for ticket conversations.Verification
fern check— 0 errors, 290 warnings (same as main)Generated with Claude Code