Update default actor build endpoint error handling and types#2483
Closed
Update default actor build endpoint error handling and types#2483
Conversation
…t 403 and add missing enum members
Error: WARN Response OpenAPI validation error {"url":"/v2/acts/{actorId}/builds/default","method":"GET","statusCode":403,"errors":[{"message":"must be equal to constant","errorCode":"const.openapi.validation","path":"/response/error/type"}]}
Files: apify-api/openapi/paths/actors/acts@{actorId}@builds@default.yaml:28-37
Root cause: The 403 response schema was hard-pinned to the const "unknown-build-tag" via UnknownBuildTagError, but the endpoint also returns 403 with type "insufficient-permissions" when an unauthenticated or non-owner caller requests a private Actor's default build. Switching the schema to the standard ErrorResponse (which references the ErrorType enum) covers both cases without losing the enum constraint.
Reference: https://github.com/apify/apify-core/tree/57a2fbf9848fa2f64043cdb855a7b95c2a6caad6/src/api/src/routes/actors/build_default.ts#L33
Error: WARN Response OpenAPI validation error {"url":"/v2/schedules","method":"POST","statusCode":400,"errors":[{"message":"must be equal to one of the allowed values: ...[truncated]","errorCode":"enum.openapi.validation","path":"/response/error/type"}]}
Files: apify-api/openapi/components/schemas/common/ErrorType.yaml:301
Root cause: When a Schedule is created with a non-JSON runInput.body, the API throws errors.scheduling.runInputBodyNotValidJson() with type "run-input-body-not-valid-json", which was missing from the ErrorType enum.
Reference: https://github.com/apify/apify-core/tree/57a2fbf9848fa2f64043cdb855a7b95c2a6caad6/src/packages/errors/src/errors/scheduling.ts#L63
Error: WARN Response OpenAPI validation error {"url":"/v2/acts/{actorId}/runs","method":"POST","statusCode":403,"errors":[{"message":"must be equal to one of the allowed values: ...[truncated]","errorCode":"enum.openapi.validation","path":"/response/error/type"}]}
Files: apify-api/openapi/components/schemas/common/ErrorType.yaml:129
Root cause: Running a public full-permission Actor without prior approval throws errors.actor.fullPermissionActorNotApproved with type "full-permission-actor-not-approved", which was missing from the ErrorType enum.
Reference: https://github.com/apify/apify-core/tree/57a2fbf9848fa2f64043cdb855a7b95c2a6caad6/src/packages/errors/src/errors/actor.ts#L58
|
Preview for this PR was built for commit |
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
This PR updates the OpenAPI specification for the default actor build endpoint to better document error responses and adds new error type definitions to the error type schema.
Key Changes
Error response documentation: Updated the 403 response for the default actor build endpoint (
GET /actors/{actorId}/builds/default) to clarify that it can be returned in two scenarios:unknown-build-tag)insufficient-permissions)Error response schema: Changed the 403 response schema from a specific
BuildErrors.yaml#/UnknownBuildTagErrorreference to the genericErrorResponse.yamlto accommodate multiple error typesNew error types: Added two new error type enums to
ErrorType.yaml:full-permission-actor-not-approvedrun-input-body-not-valid-jsonNotable Details
The 403 status code is retained for backwards compatibility despite semantically being a 404 scenario (as noted in the referenced PR #17414). The generic error response schema allows the API to return different error types while maintaining the same HTTP status code.
https://claude.ai/code/session_01WBCTVV9U7ctKjB63h9jubi