Skip to content

Conversation

@mwillbanks
Copy link
Contributor

@mwillbanks mwillbanks commented Dec 29, 2025

the error appears to be caused by the json filtering logic, it is attempting to utilize the filtering logic when there is an update on a list or json field even if there are no such values to be filtered during an update when attempting to set a new value

error response:

{
    "error": {
        "message": "Invalid array filter key: 0",
        "reason": "invalid-input",
        "rejectedByValidation": true
    }
}

Summary by CodeRabbit

  • Bug Fixes

    • Improved RPC request handling to gracefully manage requests missing serialization metadata, using safer defaults for request payloads.
  • Tests

    • Expanded test coverage to include a string-array field: creation, serialization/validation, and update flows with asserted responses.

✏️ Tip: You can customize this high-level summary in your review settings.

the error appears to be caused by the json filtering logic, it is attempting
to utilize the filtering logic when there is an update on a list or json
field even if there are no such values to be filtered during an update
when attempting to set a new value
Copilot AI review requested due to automatic review settings December 29, 2025 14:47
@coderabbitai
Copy link

coderabbitai bot commented Dec 29, 2025

📝 Walkthrough

Walkthrough

Added a stringList: String[] field to the Foo test model and updated tests to create, serialize, and update it; adjusted RPC payload processing to handle absent meta.serialization by assigning payload directly to args, otherwise preserving existing deserialization behavior.

Changes

Cohort / File(s) Summary
Test schema & RPC tests
packages/server/test/api/rpc.test.ts
Added stringList field (type String[]) to the Foo test model; introduced stringListValue = ['a','b','c'] in create data, asserted serialization and response, and added update flow patching to ['d','e','f'] with assertions.
RPC request processing
packages/server/src/api/rpc/index.ts
Updated processRequestPayload to use args ?? {} and to assign remaining payload to args when meta.serialization is absent; kept existing SuperJSON deserialization when meta.serialization exists.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I stitched a list of strings into Foo's lore,
Tiny hops of 'a','b','c' across the floor.
When metadata naps, the RPC holds the reins—
Arrays updated, deserialization remains.
Thump-thump, a rabbit nods and celebrates the gains.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'issue: rpc on update, 422 filtering error' directly addresses the core problem: a filtering error occurring during RPC update operations that causes a 422 validation error.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3042e7f and 0ae81fd.

📒 Files selected for processing (1)
  • packages/server/src/api/rpc/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/server/src/api/rpc/index.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build-test (22.x, sqlite)
  • GitHub Check: build-test (22.x, postgresql)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds regression test coverage for a bug fix that addresses a 422 filtering error when updating list or JSON fields. The error "Invalid array filter key: 0" was occurring because the filtering logic was incorrectly being applied to array values during updates, treating array indices as filter keys.

Key Changes:

  • Added a stringList String[] field to the test schema
  • Added test coverage for creating records with array field values
  • Added test coverage for updating array field values to ensure the bug is fixed

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ymc9 ymc9 merged commit 65388a5 into zenstackhq:dev Dec 30, 2025
5 of 6 checks passed
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.

2 participants