docs(openapi): Autofix OpenAPI spec validation errors#2719
Conversation
|
🗑️ Preview for this PR was deleted. |
|
Important Action required — @Pijukatel please coordinate this docs PR with the Python API client PR linked below. Because this PR modifies the OpenAPI specification, the generated models in A companion PR has been opened in
|
Fixes for response OpenAPI validation errors observed in production
apify-api logs (Jul 1-2), deduplicated to five root causes:
- Profile.yaml: bio, pictureUrl, githubUsername, websiteUrl and
twitterUsername can be null (GET /v2/users/me, GET /v2/users/{userId})
- WebhookDispatch.yaml: eventData for build events contains only actorId
and actorBuildId, so actorRunId is no longer required; added
actorBuildId and actorTaskId properties (POST /v2/webhooks/{webhookId}/test)
- BuildStats.yaml: imageSizeBytes is null in the window between the
build finishing and actor-build-analyzer writing the real value,
verified by live reproduction (POST /v2/actor-builds/{buildId}/abort)
- ErrorType.yaml: added full-permission-actor-blocked-for-admin, thrown
with 403 when starting a run (POST /v2/actors/{actorId}/runs)
- dataset-items.yaml: added 413 and 415 error responses to the shared
POST items definition (POST /v2/datasets/{datasetId}/items)
Co-Authored-By: Claude <noreply@anthropic.com>
8859767 to
96dcb07
Compare
|
Important Action required — @Pijukatel please coordinate this docs PR with the Python API client PR linked below. Because this PR modifies the OpenAPI specification, the generated models in The companion
|
- Updates the auto-generated Pydantic models and TypedDicts based on the proposed OpenAPI specification changes. - Based on apify-docs PR [#2719](apify/apify-docs#2719).
Summary
Auto-generated OpenAPI fixes suggestions based on validation errors reported by the OpenAPI validator running in staging apify-api.
apify-core version: https://github.com/apify/apify-core/tree/097f5cbed085ef8a99640a1004531b325b5c03f3
Detailed changes description
Error fixes
Nullable user profile fields
apify-api/openapi/components/schemas/users/Profile.yaml:4-23Response OpenAPI validation error {"errors":[{"errorCode":"type.openapi.validation","message":"must be string","path":"/response/data/profile/bio"},{"errorCode":"type.openapi.validation","message":"must be string","path":"/response/data/profile/githubUsername"}],"method":"GET","statusCode":200,"url":"/v2/users/{userId}"}- also raised for/profile/twitterUsername,/profile/websiteUrland/profile/pictureUrl, on bothGET /v2/users/{userId}andGET /v2/users/me(~340 occurrences, ongoing through the end of the log window).null.getProfileOfUser()copies the storedprofilevalues into the API response unchanged, so the API returnsbio: null,githubUsername: null, etc., while the spec declared these five fields as non-nullablestring. Changed them totype: [string, "null"].Webhook test dispatch
eventDatawithoutactorRunIdapify-api/openapi/components/schemas/webhook-dispatches/WebhookDispatch.yaml:28-46Response OpenAPI validation error {"errors":[{"errorCode":"required.openapi.validation","message":"must have required property 'actorRunId'","path":"/response/data/eventData/actorRunId"}],"method":"POST","statusCode":201,"url":"/v2/webhooks/{webhookId}/test?token=[REDACTED]"}processActorJobForWebhook()produceseventData = { actorId, actorBuildId }- there is noactorRunIdfor build events. TheeventDataschema required bothactorIdandactorRunIdand did not declareactorBuildIdoractorTaskIdat all (the run case produces{ actorId, actorTaskId, actorRunId }). RemovedactorRunIdfromrequired(keepingactorId, which is present in both cases) and added the missingactorBuildIdandactorTaskIdproperties.Nullable
imageSizeBytesin build statsapify-api/openapi/components/schemas/actor-builds/BuildStats.yaml:15-16Response OpenAPI validation error {"errors":[{"errorCode":"type.openapi.validation","message":"must be integer","path":"/response/data/stats/imageSizeBytes"},{"errorCode":"type.openapi.validation","message":"must be null","path":"/response/data/stats"},{"errorCode":"anyOf.openapi.validation","message":"must match a schema in anyOf","path":"/response/data/stats"}],"method":"POST","statusCode":200,"url":"/v2/actor-builds/{buildId}/abort"}imageSizeBytes: null(finishActJob/updateActorJobRecordOnFinishdo$set: { ...payload, finishedAt }with no post-processing), andactor-build-analyzeroverwrites it with the real integer computed fromdockerImageHistoryroughly 45 seconds later. Any read of the build in that window - in the logged case an abort that raced the build's completion within the same second (finishedAt08:57:22.145Z, abort logged08:57:22) and was served the just-finished document by theif (actorJob.finishedAt) return actorJobshort-circuit - returns"stats": { ..., "imageSizeBytes": null }. Againsttype: integerthenullproduces exactly the three logged errors:must be integeron the field, plusmust be nullandmust match a schema in anyOfon the parentstats(which validates asanyOf[BuildStats,null], and both branches fail). Reproduced end-to-end: a fresh build served{"durationMillis": 1000, "runTimeSecs": 1, "computeUnits": 0.0011..., "imageSizeBytes": null}from build success until the analyzer update replacednullwith531356672at t+47s. ChangedimageSizeBytestotype: [integer, "null"].Missing
full-permission-actor-blocked-for-admininErrorTypeenumapify-api/openapi/components/schemas/common/ErrorType.yaml:129Response OpenAPI validation error {"errors":[{"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"}],"method":"POST","statusCode":403,"url":"/v2/actors/{actorId}/runs"}error/typevalue is not visible because the log line is truncated, so it was identified by exclusion: diffing all error types defined in apify-core (newMeteorishErrorcalls insrc/packages/errors) against the spec enum, the only type with status 403 that is thrown in the public run-start path (validateUserCanRunActor) and missing from the enum isfull-permission-actor-blocked-for-admin, thrown when an admin account starts a full-permission Actor not managed by Apify. Added it to the enum.Missing 413 and 415 responses on dataset items POST endpoints
apify-api/openapi/components/objects/datasets/dataset-items.yaml:431-434Response OpenAPI validation error {"errors":[{"message":"no schema defined for status code '415' in the openapi spec","path":"/v2/datasets/{datasetId}/items?token=[REDACTED]"}],"method":"POST","statusCode":415,"url":"/v2/datasets/{datasetId}/items?token=[REDACTED]"}unsupported-content-encodingwhen the express body-parser rejects the request'sContent-Encoding(encoding.unsupportedis transformed in the API error middleware), but the shared POST items definition declared no 415 response. Added413and415responses (both required for endpoints withrequestBodyby this repo's error-response guidelines) referencing the existing sharedPayloadTooLarge.yamlandUnsupportedMediaType.yamlcomponents. The sharedsharedPostanchor propagates the fix to all four push-items operations (dataset_items_post, default/last-run/task-last-run variants).Issues