Skip to content

fix: make version number id consistent.#1926

Merged
JoshuaSBrown merged 1 commit intodevelfrom
1925-DAPS-bug-hotfix-web-schema-version-schema-create
Apr 1, 2026
Merged

fix: make version number id consistent.#1926
JoshuaSBrown merged 1 commit intodevelfrom
1925-DAPS-bug-hotfix-web-schema-version-schema-create

Conversation

@JoshuaSBrown
Copy link
Copy Markdown
Collaborator

@JoshuaSBrown JoshuaSBrown commented Apr 1, 2026

Ticket

Description

How Has This Been Tested?

Artifacts (if appropriate):

Tasks

  • - A description of the PR has been provided, and a diagram included if it is a new feature.
  • - Formatter has been run
  • - CHANGELOG comment has been added
  • - Labels have been assigned to the pr
  • - A reviwer has been added
  • - A user has been assigned to work on the pr
  • - If new feature a unit test has been added

Summary by Sourcery

Bug Fixes:

  • Normalize schema IDs in create requests by automatically adding a ':0' version suffix if no version is supplied.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 1, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Ensures that schema IDs created via the /api/sch/create endpoint always include an explicit :0 version suffix, matching Python CommandLib behavior.

Sequence diagram for /api/sch/create with version suffix normalization

sequenceDiagram
    participant Client
    participant ExpressApp as ExpressApp
    participant SchemaCreateHandler as SchemaCreateHandler
    participant Backend as BackendService

    Client->>ExpressApp: POST /api/sch/create { id, ... }
    ExpressApp->>SchemaCreateHandler: handleRequest(a_req, a_resp)
    SchemaCreateHandler->>SchemaCreateHandler: check a_req.body.id
    alt id has no colon
        SchemaCreateHandler->>SchemaCreateHandler: a_req.body.id = a_req.body.id + :0
    else id already has version
        SchemaCreateHandler->>SchemaCreateHandler: keep existing id
    end
    SchemaCreateHandler->>Backend: sendMessage SchemaCreateRequest(a_req.body)
    Backend-->>SchemaCreateHandler: SchemaCreateReply
    SchemaCreateHandler-->>Client: JSON response
Loading

File-Level Changes

Change Details Files
Normalize schema IDs on create requests to always include a :0 version suffix when no version is provided.
  • Add a pre-send mutation on the incoming request body for /api/sch/create to check if id is present and lacks a colon separator.
  • Append ':0' to the id value when no version suffix is found, ensuring consistent versioned IDs.
  • Leave downstream handling unchanged by still passing the (now-normalized) body into sendMessage for SchemaCreateRequest.
web/datafed-ws.js

Possibly linked issues

  • #[Bug] - web, hotfix, schema version missing from id: PR adds :0 suffix to schema IDs on create, directly fixing missing schema version in web issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Mutating a_req.body.id in-place could have unintended side effects for downstream middleware or logging; consider copying the value to a local variable or a dedicated payload object before calling sendMessage.
  • The version suffix logic is now duplicated with Python CommandLib; it may be worth centralizing this normalization in a shared utility to ensure future changes stay consistent across components.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Mutating `a_req.body.id` in-place could have unintended side effects for downstream middleware or logging; consider copying the value to a local variable or a dedicated payload object before calling `sendMessage`.
- The version suffix logic is now duplicated with Python CommandLib; it may be worth centralizing this normalization in a shared utility to ensure future changes stay consistent across components.

## Individual Comments

### Comment 1
<location path="web/datafed-ws.js" line_range="1887-1888" />
<code_context>

 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";
+    }
     sendMessage("SchemaCreateRequest", a_req.body, a_req, a_resp, function (reply) {
</code_context>
<issue_to_address>
**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) { ... }`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread web/datafed-ws.js
Comment on lines +1887 to +1888
if (a_req.body.id && a_req.body.id.indexOf(":") === -1) {
a_req.body.id = a_req.body.id + ":0";
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) { ... }.

@JoshuaSBrown JoshuaSBrown merged commit 920f1b8 into devel Apr 1, 2026
4 of 5 checks passed
JoshuaSBrown added a commit that referenced this pull request Apr 1, 2026
* [DAPS-1925] - fix: make version number id consistent. (#1926)

 Co-authored-by: JoshuaSBrown <brownjs@ornl.gov>
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.

1 participant