Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Comment on lines
+176
to
+180
| props.onChange({ | ||
| subject: field, | ||
| operator: ops?.includes(props.condition.operator) ? props.condition.operator : ops?.[0], | ||
| value: null, | ||
| }); |
There was a problem hiding this comment.
Bug: Changing a predicate's subject sets its value to null, which is not allowed by the Zod schema, causing an immediate validation error to appear during form editing.
Severity: MEDIUM
Suggested Fix
Either update the Zod schema in schema.ts to permit null values by adding .nullable() to the value field definition, or modify RuleForm.tsx to set the value to an empty string ('') instead of null when the subject changes.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: components/accounting/dashboard/categorization/RuleForm.tsx#L176-L180
Potential issue: When a user edits a categorization rule and changes a predicate's
`subject` field, the `onChange` handler in `RuleForm.tsx` programmatically sets the
corresponding `value` field to `null`. However, the Zod validation schema for the form
does not permit `null` for this field. Because validation is triggered on every field
change, this immediately and incorrectly displays a validation error to the user,
disrupting the form editing experience even though the user has not finished their
input.
Did we get this right? 👍 / 👎 to inform future reviews.
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.
Require opencollective/opencollective-api#11456