Fix dataset schema payload types and release v3.0.4#81
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 16 minutes and 36 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughVersion number incremented from 3.0.3 to 3.0.4 across package metadata files. Dataset schema updated to accept Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates the Actor’s dataset schema so logged webhook payload fields (body, responseBody) can be stored as structured JSON (not only strings), adds a regression test to keep the schema aligned, and bumps the release metadata to v3.0.4.
Changes:
- Relax
.actor/dataset_schema.jsonto accept object payloads forbodyandresponseBody. - Add a Jest regression test validating both string and object payload shapes against the dataset schema.
- Bump version to
3.0.4and sync changelog + Actor/OpenAPI metadata.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/actor/input_schema.test.js | Adds Ajv-based regression validation for dataset schema payload shapes. |
| .actor/dataset_schema.json | Expands body/responseBody types to include objects; reformats examples/view config. |
| package.json | Bumps package version to 3.0.4. |
| package-lock.json | Updates lockfile version fields to 3.0.4. |
| CHANGELOG.md | Adds 3.0.4 entry describing the schema relaxation + test. |
| .actor/web_server_schema.json | Syncs OpenAPI version/example strings to 3.0.4. |
| .actor/actor.json | Syncs Actor metadata version to 3.0.4. |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
tests/unit/actor/input_schema.test.js (1)
136-157: Strengthen the regression test with negative cases and broader shapes.The current test only covers the happy path for
stringandobject. Two small additions would make the regression meaningfully tighter:
- Assert a disallowed shape (e.g.
body: 123orbody: true) fails validation — otherwise a future schema change that accidentally widensbodyto{}(any type) would silently pass.- Cover real runtime outputs:
bodyas an array (common for JSON-array webhooks) andresponseBody: null(perLogDetailResponse.nullable: truein the web server schema) to surface the schema drift noted in.actor/dataset_schema.json.🧪 Proposed additions
expect(validate.errors).toBeNull(); + + // Negative case: scalar bodies should not validate under the current schema. + expect(validate({ body: 123 })).toBe(false); + + // Real-world shapes captured by jsonParserMiddleware. + expect(validate({ body: [{ event: "x" }] })).toBe(true); });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unit/actor/input_schema.test.js` around lines 136 - 157, Update the unit test that compiles datasetSchema.fields (using Ajv/validate) to add negative and broader positive cases: assert that invalid types for body (e.g., number or boolean like body: 123 or body: true) cause validate(...) to return false and validate.errors to be non-null, and add additional positive cases such as body as an array (e.g., []/[*]) and responseBody: null to ensure those runtime shapes are accepted; locate the test block using describe("Apify dataset schema") and the validate variable to insert these assertions..actor/dataset_schema.json (1)
60-74: Alignbody/responseBodytypes across both dataset and web server schemas.The dataset schema (lines 60-74 and 117-131) accepts only
stringorobject, but the web server schema acceptsobject,array,string,number, andboolean. SincejsonParserMiddlewarecan parse webhooks into any JSON type andActor.pushData(event)in logger_middleware.js passes the parsed body directly, the dataset schema should include all possible JSON types to prevent validation failures and schema drift.♻️ Proposed alignment
"body": { "oneOf": [ - { - "type": "string" - }, - { - "type": "object" - } + { "type": "string" }, + { "type": "object" }, + { "type": "array" }, + { "type": "number" }, + { "type": "boolean" } ],Apply the same to
responseBody(lines 117-131).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.actor/dataset_schema.json around lines 60 - 74, The dataset schema's "body" and "responseBody" definitions currently only allow "string" or "object", which can fail when jsonParserMiddleware parses webhooks into other JSON types; update the "oneOf" for both "body" and "responseBody" in .actor/dataset_schema.json to match the web server schema by including "object", "array", "string", "number", and "boolean" (i.e., add entries for type "array", type "number", and type "boolean") so Actor.pushData(event) will validate all JSON payloads the middleware can produce.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.actor/dataset_schema.json:
- Around line 60-74: The dataset schema's "body" and "responseBody" definitions
currently only allow "string" or "object", which can fail when
jsonParserMiddleware parses webhooks into other JSON types; update the "oneOf"
for both "body" and "responseBody" in .actor/dataset_schema.json to match the
web server schema by including "object", "array", "string", "number", and
"boolean" (i.e., add entries for type "array", type "number", and type
"boolean") so Actor.pushData(event) will validate all JSON payloads the
middleware can produce.
In `@tests/unit/actor/input_schema.test.js`:
- Around line 136-157: Update the unit test that compiles datasetSchema.fields
(using Ajv/validate) to add negative and broader positive cases: assert that
invalid types for body (e.g., number or boolean like body: 123 or body: true)
cause validate(...) to return false and validate.errors to be non-null, and add
additional positive cases such as body as an array (e.g., []/[*]) and
responseBody: null to ensure those runtime shapes are accepted; locate the test
block using describe("Apify dataset schema") and the validate variable to insert
these assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ed014e6a-0cb4-49ef-8e03-d0e8f04d7735
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (6)
.actor/actor.json.actor/dataset_schema.json.actor/web_server_schema.jsonCHANGELOG.mdpackage.jsontests/unit/actor/input_schema.test.js
Summary
.actor/dataset_schema.jsonto accept object payloads forbodyandresponseBody3.0.4, sync generated actor metadata, and update the changelogVerification
npm run validate:schemasnpm run test:jest -- tests/unit/actor/input_schema.test.jsSummary by CodeRabbit
Version 3.0.4 Release Notes
Bug Fixes
Documentation
Tests