Skip to content

Update Staging#1869

Merged
nedvedba merged 2 commits intostagingfrom
devel
Feb 23, 2026
Merged

Update Staging#1869
nedvedba merged 2 commits intostagingfrom
devel

Conversation

@nedvedba
Copy link
Collaborator

@nedvedba nedvedba commented Feb 23, 2026

Update Staging

Summary by Sourcery

Align web server version and API compatibility handling with updated version metadata and response field names, and normalize protobuf message handling for core socket responses.

Enhancements:

  • Switch web client version constants to use generic release and semantic version fields from the shared version module.
  • Update API version and release metadata checks to use camelCase fields from the core server reply.
  • Normalize protobufjs response messages to plain JavaScript objects with defaults before invoking callbacks.

#1861)

* fix: prevent defaults being set to undefined, and interpret numbers and enums as strings.

* chore: Auto-format JavaScript files with Prettier
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 23, 2026

Reviewer's Guide

Aligns web server versioning and API compatibility checks with updated version fields and message schema, and ensures protobuf messages are converted to plain objects with defaults before handler execution.

Sequence diagram for updated API version compatibility check in startServer

sequenceDiagram
    participant Client
    participant WebServer
    participant CoreServer
    participant Logger

    Client->>WebServer: startServer()
    WebServer->>CoreServer: Connect and send version request
    CoreServer-->>WebServer: reply(apiMajor, apiMinor, apiPatch, releaseYear, releaseMonth, releaseDay, releaseHour, releaseMinute)

    WebServer->>WebServer: Compare reply.apiMajor with g_ver_api_major
    alt Incompatible_major_or_minor
        WebServer->>Logger: error("ERROR: Incompatible api version detected (apiMajor.apiMinor.apiPatch)")
    else Compatible_major_and_minor
        WebServer->>WebServer: Compare releaseYear/Month/Day/Hour/Minute
        alt Newer_release_available
            WebServer->>Logger: warning("WARNING: A newer web server may be available...")
        else Up_to_date_or_older
            WebServer->>Logger: info("Web server version compatible")
        end
    end
Loading

Sequence diagram for protobuf message conversion before handler execution

sequenceDiagram
    participant CoreServer
    participant CoreSocket as g_core_sock
    participant Dispatcher as ContextDispatcher
    participant ProtoTypeResolver
    participant Handler as MessageHandler

    CoreServer-->>CoreSocket: message(ctx, msg, which_field, msg_info)
    CoreSocket->>Dispatcher: Lookup context by correlation_id
    Dispatcher-->>CoreSocket: ctx, handler f

    alt msg is not null
        CoreSocket->>ProtoTypeResolver: resolve_type = msg_info.type
        alt which_field is set
            ProtoTypeResolver->>ProtoTypeResolver: actual_entry = find in g_msg_by_id by field_name
            ProtoTypeResolver->>ProtoTypeResolver: resolve_type = actual_entry.type
        end
        alt resolve_type is set
            ProtoTypeResolver->>ProtoTypeResolver: msg = resolve_type.toObject(msg, defaults=true, longs=String, enums=String)
        end
    end

    CoreSocket->>Handler: f(msg)  %% msg is now plain object with defaults
Loading

File-Level Changes

Change Details Files
Align version globals with new version module API and expose API semantic version components.
  • Switched global release date/time variables from DATAFED_RELEASE_* constants to RELEASE_* constants provided by the version module.
  • Added new globals for API semantic version (major, minor, patch) sourced from the version module.
web/datafed-ws.js
Update compatibility checks and release warning logic to match new core reply field naming.
  • Replaced usage of snake_case reply fields for API version with camelCase equivalents in compatibility condition and error message logging.
  • Updated release comparison and warning message construction to use camelCase reply fields for year, month, day, hour, and minute.
web/datafed-ws.js
Normalize protobuf replies to plain JS objects with defaults before invoking message handlers.
  • Resolved the correct protobuf type for the current message, optionally using which_field indirection via g_msg_by_id.
  • Converted the protobufjs message to a plain object with defaults enabled and longs/enums serialized as strings before calling the handler callback.
web/datafed-ws.js

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

@nedvedba nedvedba merged commit d41bc46 into staging Feb 23, 2026
3 of 5 checks passed
Copy link
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 left some high level feedback:

  • The new protobuf-to-plain-object conversion block does a linear Object.values(g_msg_by_id).find(...) on every message; if this path is hot, consider maintaining a direct field_name -> entry map to avoid repeated full scans.
  • Before calling resolve_type.toObject(...), it may be safer to guard that resolve_type && typeof resolve_type.toObject === 'function' to avoid runtime errors if the type metadata is missing or malformed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new protobuf-to-plain-object conversion block does a linear `Object.values(g_msg_by_id).find(...)` on every message; if this path is hot, consider maintaining a direct `field_name -> entry` map to avoid repeated full scans.
- Before calling `resolve_type.toObject(...)`, it may be safer to guard that `resolve_type && typeof resolve_type.toObject === 'function'` to avoid runtime errors if the type metadata is missing or malformed.

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.

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.

2 participants