Conversation
#1861) * fix: prevent defaults being set to undefined, and interpret numbers and enums as strings. * chore: Auto-format JavaScript files with Prettier
Contributor
Reviewer's GuideAligns 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 startServersequenceDiagram
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
Sequence diagram for protobuf message conversion before handler executionsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
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 directfield_name -> entrymap to avoid repeated full scans. - Before calling
resolve_type.toObject(...), it may be safer to guard thatresolve_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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: