Skip to content

Minimal referenceable error responses + reusable error examples#665

Open
hdamker wants to merge 5 commits into
camaraproject:mainfrom
hdamker:feat/663-error-response-redesign
Open

Minimal referenceable error responses + reusable error examples#665
hdamker wants to merge 5 commits into
camaraproject:mainfrom
hdamker:feat/663-error-response-redesign

Conversation

@hdamker

@hdamker hdamker commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • enhancement/feature

What this PR does / why we need it:

Implements the proposed "Option 3" in #663: the Generic* error responses bundle error codes that do not apply to every API, so every API referencing them declares error codes it can never return (#662 is the acute case).

  • CAMARA_common.yaml: adds a catalogue of 10 minimal, directly referenceable error responses (BadRequest400, BadRequestWithRange400, Unauthenticated401, PermissionDenied403, NotFound404, IdentifierNotFound404, AlreadyExists409, DeviceIdentifier422, PhoneNumberIdentifier422, TooManyRequests429), each containing only error codes every referencing API can return, plus a new components/examples section with the canonical error examples — including those of codes without a referenceable response — for APIs defining error responses locally. Identifier-code examples come in _DEVICE / _PHONE_NUMBER wording variants; per HTTP status an intro comment lists the available responses and example ingredients.
  • CAMARA_event_common.yaml: adds CreateSubscriptionConflict409, SinkGone410 (replacing Generic410 for notification callbacks) and the subject-flavoured CreateSubscriptionDevice422 / CreateSubscriptionPhoneNumber422; existing responses now reference the shared examples, removing the example duplication between the two files.
  • The Generic* responses and CreateSubscriptionUnprocessableEntity422 stay in place as deprecated and content-frozen, with two bug fixes: INVALID_TOKEN_CONTEXT removed from Generic403 (Make INVALID_TOKEN_CONTEXT opt-in in the shared Generic403 #662) and the deprecated 409 code CONFLICT removed (enum and example).
  • The API templates, the notification template, and Design Guide section 3.2 are updated to the new consumption model: reference a catalogue response, or define the response locally and reference the shared examples.

Which issue(s) this PR fixes:

Fixes #663
Fixes #662

Does this PR introduce a breaking change?

  • Yes
  • No

No released API references the CAMARA_common.yaml responses via external $ref (all released definitions hold local copies), and the deprecated responses remain valid referencing targets. Removal of the deprecated responses is proposed for the next meta-release cycle.

Special notes for reviewers:

  • sample-notification.yaml also switched to the new response names and now declares 410 (SinkGone410), which the Event Subscription and Notification Guide requires for the notification flow but the template was missing.
  • A GENERIC_400_INVALID_TOKEN example was added to CAMARA_event_common.yaml: the INVALID_TOKEN code was listed in the enum of CreateSubscriptionBadRequest400 but had no example anywhere — please review the proposed wording.
  • GENERIC_404_IDENTIFIER_NOT_FOUND and GENERIC_422_SERVICE_NOT_APPLICABLE now use subject-neutral wording (previously device-worded, also for phone-number APIs); the message example in Design Guide section 3.2.2 is aligned.
  • Response names follow the purpose/flavour + status-suffix precedent set by CAMARA_event_common.yaml; the Generic* names are not reused, to avoid silently changing the meaning of existing references.

Changelog input

 release-note
Added minimal referenceable error responses and a shared components/examples section to CAMARA_common.yaml and CAMARA_event_common.yaml; Generic* error responses and CreateSubscriptionUnprocessableEntity422 are deprecated (removal planned for the next meta-release cycle); INVALID_TOKEN_CONTEXT removed from Generic403; deprecated 409 code CONFLICT removed.

Additional documentation

This section can be blank.

…project#663)

Replace the Generic* superset responses with minimal referenceable error
responses (10 in CAMARA_common.yaml, subscription-specific ones in
CAMARA_event_common.yaml) and add components/examples as shared
ingredients for locally defined responses, so each API declares only the
error codes it can return. Generic* responses (and
CreateSubscriptionUnprocessableEntity422) stay deprecated-but-present for
existing references, with two bug fixes: INVALID_TOKEN_CONTEXT removed
from Generic403 (camaraproject#662) and the deprecated 409 code CONFLICT removed. API
templates, the notification template, and the Design Guide error-response
sections are updated to the new consumption model.
# - The `allOf` in content.application/json.schema allows a combination of both the generic ErrorInfo schema and the specific schema for this error response,
# which validates that `status` and `code` have only the specified values.
# This `allOf` is used without discriminator because it does not imply any hierarchy between the models, just 2 schemas that must be independently validated.
#######################################################

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment.
Maybe we can keep Lines 376-404 as commented info that may help in case an initiative needs to define API-specific error codes, or a code combination not covered by this catalogue

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Rather than restore the full commented ErrorResponseSchema block inline here — the redesign moved copy-me forms out of CAMARA_common.yaml to avoid mixing referenceable definitions with templates — the catalogue intro now points to a complete, copy-ready locally-defined response in artifacts/api-templates/sample-service.yaml and calls it out as the skeleton for API-specific codes or code combinations this catalogue does not cover. I have updated the intro comment to make that explicit in commit 82a8f1d.

Comment thread artifacts/common/CAMARA_common.yaml Outdated
# DEPRECATED error responses
#
# The Generic* responses below are DEPRECATED as of Commonalities 0.9.0
# and are planned for removal in the next meta-release cycle. They bundle

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion (up to WG consideration):

Instead of being removed, would prefer to mention to have it Deprecated but documented (with # as noted text) so having them them as a consultation information but not being directly referenciable.

That is to have some guidance for API designers and API Providers implementing errors not explicitly mentioned in the API Specification. We had some discussion in the past about that point in #438

It works with examples section from pragmatical point of view, but i am afraid this generates confusion again in the future.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree this is worth keeping as consultation guidance rather than losing it. That removal happens in the next meta-release cycle, not in this PR, so I have softened the banner: the Generic* responses are now noted as planned for removal or downgrade to a commented-out reference in commit 82a8f1d. The exact mechanic — delete versus keeping them as # reference text, as discussed in #438 — is a good decision for the WG to take at that removal step. Flagging it for then.

# callbacks; local definition from GENERIC_410_GONE otherwise
# Generic422 → DeviceIdentifier422 or PhoneNumberIdentifier422
# Generic429 → TooManyRequests429
# Generic405, Generic406, Generic412, Generic415, Generic5xx →

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE:

  • From our view 405, 406, 412, 415 and 5xx are single error code cases (not foreseen multiple codes would be allowed in the feature) so it could remain directly referenciable.

Anyway this approach will work

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right that there is no superset risk for these single-code statuses. The reason they are examples-only rather than referenceable responses is not the superset — it is the Design Guide's "not documented by default" guidance for 405/406/412/415/5xx. Keeping them out of the referenceable catalogue avoids nudging APIs to document statuses the guide says to omit, while the canonical examples stay available for the rare justified case. Happy to revisit if the WG wants to reconsider the "not documented by default" stance separately.

Comment thread documentation/CAMARA-API-Design-Guide.md Outdated
hdamker and others added 3 commits July 10, 2026 16:20
Co-authored-by: Pedro Díez García <pedro.diezgarcia@telefonica.com>
…val note

Address PR camaraproject#665 review: frame the sample-service.yaml pointer as the
copy-ready skeleton for codes the catalogue does not cover, and note the
deprecated Generic* responses may be downgraded to a commented-out
reference rather than removed outright.
@hdamker hdamker requested a review from PedroDiez July 13, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error responses in CAMARA_common.yaml have limited reusability Make INVALID_TOKEN_CONTEXT opt-in in the shared Generic403

2 participants