Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions web/datafed-ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,10 @@ app.post("/api/sch/search", (a_req, a_resp) => {
});

app.post("/api/sch/create", (a_req, a_resp) => {
// Mirror Python CommandLib: ensure :0 version suffix on create
if (a_req.body.id && a_req.body.id.indexOf(":") === -1) {
a_req.body.id = a_req.body.id + ":0";
Comment on lines +1887 to +1888

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Guard against non-string id to avoid runtime errors when calling indexOf.

If a_req.body.id is ever non-string (e.g. number or object), calling indexOf will throw. To avoid runtime errors on malformed input, first ensure it’s a string, e.g. if (typeof a_req.body.id === 'string' && a_req.body.id.indexOf(':') === -1) { ... }.

}
sendMessage("SchemaCreateRequest", a_req.body, a_req, a_resp, function (reply) {
a_resp.json(reply);
});
Expand Down
Loading