fix: validate-metadata-required-for-on-all-entities#6658
fix: validate-metadata-required-for-on-all-entities#6658
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Docker builds report
|
…ed-metadata-validation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| toast(getMetadataErrors(result.error as MetadataErrorResponse), 'danger') | ||
| } else { | ||
| toast('Environment Field Updated') | ||
| setHasChanges(false) |
There was a problem hiding this comment.
Environment save reverts UI to stale cached data
High Severity
After a successful environment metadata save, setHasChanges(false) triggers the useEffect at line 77 which checks !hasChanges. Since updateEnvironment only invalidates Environment tags (not Metadata tags), the initialFields from useGetEntityMetadataFieldsQuery remains stale with pre-edit values. The effect then overwrites metadataFields with those stale values, visually reverting the user's just-saved changes.
Additional Locations (1)
| } | ||
|
|
||
| return updatedMetadataFields | ||
| }) |
There was a problem hiding this comment.
Side effect inside React state updater function
Low Severity
The onChange callback is invoked inside the setMetadataFields updater function, which React requires to be pure. In React 18 strict mode (development), updater functions are called twice to detect impurities, which would cause onChange to fire twice per user change. Moving the onChange call outside the updater (e.g., after setMetadataFields) would keep the updater pure and avoid the double-fire in development.


Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Closes #6520
Includes a refactor of the logic in order to prepare #6620
mergeMetadataFieldsandmetadataValidationin a utils + unit testsHow did you test this code?