Skip to content

fix(guard): serialize gateway actor keys correctly#4655

Open
NathanFlurry wants to merge 1 commit intobreak-up/subscribe-before-namespace-dispatchfrom
break-up/serialize-gateway-actor-keys
Open

fix(guard): serialize gateway actor keys correctly#4655
NathanFlurry wants to merge 1 commit intobreak-up/subscribe-before-namespace-dispatchfrom
break-up/serialize-gateway-actor-keys

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Member Author

NathanFlurry commented Apr 14, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude bot commented Apr 14, 2026

Code Review for PR 4655 - fix(guard): serialize gateway actor keys correctly

Overview

This PR fixes a semantic bug in serialize_actor_key. The original code used EMPTY_KEY in the join() call instead of KEY_SEPARATOR. Both constants share the same string value so there is no observable behavioral change, but the intent was wrong and the naming misleading.

What Changed

The root cause: KEY_SEPARATOR was typed as char, which cannot be passed to slice::join() (requires &str). The workaround was to use EMPTY_KEY (same value) for the join. The fix properly types KEY_SEPARATOR as &str and adds KEY_SEPARATOR_CHAR: char for the replace() call.

  • Before: KEY_SEPARATOR as char, escaped_parts.join(EMPTY_KEY) -- wrong constant, coincidentally same value
  • After: KEY_SEPARATOR as &str, KEY_SEPARATOR_CHAR as char, escaped_parts.join(KEY_SEPARATOR) -- semantically correct

Assessment

Correct fix. Resolves the semantic confusion without any behavior change.

Minor suggestions:

  1. Test coverage: No unit tests exist for serialize_actor_key. Since this function serializes actor keys used in both resolve_query_get_actor_id and resolve_query_get_or_create_actor_id, adding tests would be valuable covering: empty key, single part, multi-part, parts containing slash (escaped), backslash (escaped), and empty string parts.

  2. Constant documentation (optional): Having both EMPTY_KEY and KEY_SEPARATOR with the same underlying value '/' is still a little confusing. A short inline comment clarifying that EMPTY_KEY represents the serialized form of an empty key slice (early-return only) while KEY_SEPARATOR is the join delimiter would help future readers avoid the same mix-up.

Verdict

The fix is correct and clean. The only meaningful follow-up is adding unit tests for serialize_actor_key to guard against future regressions.

@NathanFlurry NathanFlurry marked this pull request as ready for review April 15, 2026 01:09
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