-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug where schema notification errors are not triggered when custo… #1287
base: devel
Are you sure you want to change the base?
Fix bug where schema notification errors are not triggered when custo… #1287
Conversation
…m metadata is empty
Reviewer's Guide by SourceryThe pull request fixes a bug where schema notifications were not triggered when a custom metadata field was not specified. The fix ensures that empty curly braces are set as the default value for the metadata field, which triggers the schema validation errors. Sequence diagram for record creation with metadata validationsequenceDiagram
participant Client
participant DataRouter
participant SchemaValidator
Client->>DataRouter: Create record (no metadata)
activate DataRouter
Note right of DataRouter: Set empty metadata {}
DataRouter->>SchemaValidator: Validate record
activate SchemaValidator
SchemaValidator-->>DataRouter: Return validation result
deactivate SchemaValidator
alt validation fails
DataRouter-->>Client: Return error
else validation passes
DataRouter-->>Client: Return success
end
deactivate DataRouter
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @JoshuaSBrown - I've reviewed your changes - here's some feedback:
Overall Comments:
- The empty metadata should be set as an empty object ({}) rather than a string ('{}') to maintain type consistency and prevent potential issues with code expecting an object.
- Consider adding a unit test to verify this behavior and prevent future regressions.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@@ -557,12 +557,17 @@ export function show(a_mode, a_data, a_parent, a_upd_perms, a_cb) { | |||
$("#sch_id", frame).val(a_data.schId); | |||
} | |||
|
|||
var md; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move away from using var
, instead we can use let
https://www.geeksforgeeks.org/difference-between-var-and-let-in-javascript/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: md is not reallt descriptive enough. I can't arrive at metadata. I think of a medium t-shirt 👕
} else { | ||
md = {}; // Set empty metadata to an empty JSON object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I apprecaite the comment on setting the metadata object to blank, maybe we can comment what the:
var md = JSON.parse(a_data.metadata);
var txt = JSON.stringify(md, null, 4);
jsoned.setValue(txt, -1);
logic is doing and why.
@@ -99,9 +99,14 @@ function recordCreate(client, record, result) { | |||
} | |||
} | |||
|
|||
// If no custom metadata is provided by the user empty curly braces should | |||
// be set so as to trigger schema validation errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty curly braces 👁️👄👁️
So if no custom metadata exists, we trigger schema validation with an empty object
…m metadata is empty
PR Description
Fixes bug where schema notifications are not being triggered when custom metadata field has not been specified.
Tasks
Summary by Sourcery
Bug Fixes: