Skip to content

Commit edda3dc

Browse files
Pijukatelclaude
andauthored
docs(openapi): Autofix OpenAPI spec validation errors (#2859)
## Summary Autogenerated OpenAPI fixes suggestions based on validation errors generated from running API integration tests with OpenAPI validator turned on. **Error log:** production API error logs (Mesmo, `apify-api` SOFT_FAIL entries) supplied as uploaded files - iteration 1: `0697c937-errors` (Aug 3-9, 2026, 600 lines); iteration 2: `82f6eccd-errors` (Aug 20-27, 2026, 599 lines). These are production logs with no public URL, so they are referenced by name for the lifetime of the PR. **apify-core version:** iteration 1 apify/apify-core@6a88dd0, iteration 2 apify/apify-core@59575e6 **Stop reason:** enough errors fixed - every unique error in both logs is either fixed here or documented below. The branch was rebased onto master before iteration 2, since the `publicConfig` schemas referenced by the second log landed in master after iteration 1. Each fix references the apify-core commit of its own iteration. ## Detailed changes description ### Error fixes #### Allow `null` in `ActorNotice` enum - **Files:** `apify-api/openapi/components/schemas/actors/ActorNotice.yaml:5-10` - **Error:** `{"errorCode":"enum.openapi.validation","message":"must be equal to one of the allowed values: NONE, RESIDENTIAL_PROXY_REQUIRED, UNDER_MAINTENANCE","path":"/response/data/items/{N}/notice"}` on `GET /v2/store` and `{"path":"/response/data/notice"}` on `GET /v2/actors/{actorId}` - by far the largest group in both logs (~2093 item-level errors in iteration 1, 2322 in iteration 2) - **Root cause:** The schema declares `type: [string, "null"]` but the `enum` lists only the three string values. In JSON Schema (OpenAPI 3.1) `enum` is exhaustive, so a `null` instance fails validation unless `null` is itself an enum member. The API does return `notice: null` - the store pipeline stores `notice: actor.notice ?? null`, the store item type is `notice: string | null`, and the API's own test fixture shapes a response with `notice: null`. The underlying representation inconsistency in apify-core is tracked in apify/apify-core#29871. - **Reference:** https://github.com/apify/apify-core/blob/6a88dd05/src/packages/actor-server/src/recombee/recombee_store_sync.ts#L555, https://github.com/apify/apify-core/blob/6a88dd05/src/api/test/tests/routes/store_search.test.ts#L50 #### Drop `format: uri` from store item `pictureUrl` - **Files:** `apify-api/openapi/components/schemas/store/StoreListActor.yaml:37-39` - **Error:** `{"errorCode":"format.openapi.validation","message":"must match format \"uri\"","path":"/response/data/items/{N}/pictureUrl"}` on `GET /v2/store` (3 lines) - **Root cause:** `Actor.pictureUrl` is a free-form string in apify-core (`type: String, max: 300`, no URI validation), and the store search response rewrites it through the image proxy only when the value is truthy - an empty or malformed legacy value is passed through verbatim, so the response cannot guarantee RFC 3986 `uri` format. This also makes `StoreListActor.pictureUrl` consistent with `Actor.yaml`'s `pictureUrl`, which declares no `format`. - **Reference:** https://github.com/apify/apify-core/blob/6a88dd05/src/packages/actor/src/actors/actors.both.ts#L673, https://github.com/apify/apify-core/blob/6a88dd05/src/packages/actor/src/actors/actors_store.both.ts#L169 #### Add `401` response to `GET /v2/users/{userId}` - **Files:** `apify-api/openapi/paths/users/users@{userId}.yaml:30-31` - **Error:** `{"message":"no schema defined for status code '401' in the openapi spec","path":"/v2/users/{userId}"}` (statusCode 401, 1 line, username normalized to `{userId}`) - **Root cause:** The endpoint requires no authentication, but the global authentication middleware validates any token that is provided. A request carrying an invalid token is rejected with 401 `user-or-token-not-found` before the handler runs, so the operation can return 401 even though it is otherwise public. Compliant with RFC 9110 §15.5.2 (request "lacks valid authentication credentials"). Reuses the shared `Unauthorized.yaml` response component. - **Reference:** https://github.com/apify/apify-core/blob/6a88dd05/src/api/src/middleware/authentication.ts#L95, https://github.com/apify/apify-core/blob/6a88dd05/src/packages/errors/src/errors/iam.ts#L58 #### Add `cannot-publish-actor-task` to the `ErrorType` enum - **Files:** `apify-api/openapi/components/schemas/common/ErrorType.yaml:72` - **Error:** `{"errorCode":"enum.openapi.validation","message":"must be equal to one of the allowed values: 3d-secure-auth-failed, access-right-already-exists, action-not-foun...[truncated]","path":"/response/error/type"}` on `POST /v2/actor-tasks` and `PUT /v2/actor-tasks/{actorTaskId}`, both status 400 - **Root cause:** Failed task publication validation returns 400 with error type `cannot-publish-actor-task`, which the enum did not list. The log truncates the allowed-values list, so the missing member was identified by diffing every `newMeteorishError` code in apify-core against the enum: `cannot-publish-actor-task` is the only absent code that is both status 400 and reachable from these endpoints, and an integration test asserts exactly this status and type. `cannot-unpublish-actor-task` is also absent from the enum but is thrown only by the Console backend, never the public API, so it is deliberately not added. - **Reference:** https://github.com/apify/apify-core/blob/59575e6d/tests/integration/tests/actor_tasks/actor_tasks.publication.js#L370, https://github.com/apify/apify-core/blob/59575e6d/src/packages/errors/src/errors/actor_task.ts#L58 #### Add `409` response to `PUT /v2/schedules/{scheduleId}` - **Files:** `apify-api/openapi/paths/schedules/schedules@{scheduleId}.yaml:86-87` - **Error:** `{"message":"no schema defined for status code '409' in the openapi spec","path":"/v2/schedules/{scheduleId}"}` (statusCode 409, 2 lines) - **Root cause:** Renaming a schedule to a name another of the user's schedules already holds trips the unique index `{userId, nameLowerCase}`; `insertOrUpdateSchedule` catches the duplicate-key error and throws `schedule-name-not-unique` with status 409, which the operation did not document. RFC 9110 §15.5.10 covers this case exactly, `schedule-name-not-unique` is already in the `ErrorType` enum, and `POST /v2/schedules` already documents 409 for the same condition - `PUT` was the outlier. Reuses the shared `Conflict.yaml` response component. - **Reference:** https://github.com/apify/apify-core/blob/59575e6d/src/packages/actor-server/src/schedules.ts#L436, https://github.com/apify/apify-core/blob/59575e6d/src/packages/mongo-indexes/src/schedules.ts#L13 ## Issues Partially implements: #2286 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 83f9cf1 commit edda3dc

5 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎apify-api/openapi/components/schemas/actors/ActorNotice.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ enum:
66
- NONE
77
- RESIDENTIAL_PROXY_REQUIRED
88
- UNDER_MAINTENANCE
9+
- null # https://github.com/apify/apify-core/issues/29871, https://github.com/cdimascio/express-openapi-validator/issues/165
910
examples: [UNDER_MAINTENANCE]

‎apify-api/openapi/components/schemas/common/ErrorType.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ enum:
6969
- cannot-override-paid-actor-trial
7070
- cannot-permanently-delete-subscription
7171
- cannot-publish-actor
72+
- cannot-publish-actor-task
7273
- cannot-reduce-last-full-token
7374
- cannot-reimburse-more-than-original-charge
7475
- cannot-reimburse-non-rental-charge

‎apify-api/openapi/components/schemas/store/StoreListActor.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ properties:
3636
$ref: ../actors/ActorNotice.yaml
3737
pictureUrl:
3838
type: [string, "null"]
39-
format: uri
4039
examples: ["https://..."]
4140
userPictureUrl:
4241
type: [string, "null"]

‎apify-api/openapi/paths/schedules/schedules@{scheduleId}.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ put:
8383
$ref: ../../components/responses/NotFound.yaml
8484
"405":
8585
$ref: ../../components/responses/MethodNotAllowed.yaml
86+
"409":
87+
$ref: ../../components/responses/Conflict.yaml
8688
"413":
8789
$ref: ../../components/responses/PayloadTooLarge.yaml
8890
"415":

‎apify-api/openapi/paths/users/users@{userId}.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ get:
2727
$ref: ../../components/schemas/users/PublicUserDataResponse.yaml
2828
"400":
2929
$ref: ../../components/responses/BadRequest.yaml
30+
"401":
31+
$ref: ../../components/responses/Unauthorized.yaml
3032
"404":
3133
$ref: ../../components/responses/NotFound.yaml
3234
"405":

0 commit comments

Comments
 (0)