Skip to content

Conversation

@emsearcy
Copy link
Contributor

Description

Implements lfx.lookup_v1_mapping NATS function for bidirectional v1↔v2 ID mapping lookups as specified in LFXV2-1011.

Changes

Core Implementation

  • NATS Queue Subscription: Uses natsConn.QueueSubscribe pattern for scalable request handling
  • Bidirectional Lookup: Supports both v1→v2 and v2→v1 mapping queries based on key format
  • Error Handling: Returns "error: {message}" for NATS/service errors, empty string for not found
  • Tombstone Support: Handles deleted mappings gracefully by returning empty string

Files Changed

  • cmd/lfx-v1-sync-helper/main.go: Added subscription to lfx.lookup_v1_mapping subject
  • cmd/lfx-v1-sync-helper/lookup_handler.go: New handler implementing the lookup logic
  • README.md: Comprehensive documentation with lookup patterns table and error handling guide

Supported Lookup Patterns

  • Projects: project.sfid.{v1_sfid}project.uid.{v2_uuid}
  • Committees: committee.sfid.{v1_sfid}committee.uid.{v2_uuid}
  • Committee Members: committee_member.sfid.{v1_sfid}committee_member.uid.{v2_uuid}

Technical Details

The function:

  1. Receives mapping key as request payload
  2. Queries v1-mappings NATS KV bucket
  3. Returns mapped value, empty string (not found), or error response
  4. Handles tombstoned mappings by returning empty string

Testing

  • ✅ Code compiles successfully
  • ✅ Follows existing code patterns and error handling
  • ✅ Documentation includes comprehensive usage examples

JIRA

LFXV2-1011: Create NATS lookup function for v1-v2 mapping

Implements lfx.lookup_v1_mapping NATS function for bidirectional v1↔v2
ID mapping lookups as specified in LFXV2-1011.

Key features:
- Queue-based subscription using natsConn.QueueSubscribe pattern
- Bidirectional lookup support (v1→v2 and v2→v1)
- Error handling with 'error: ' prefixed responses
- Empty string responses for not found/tombstoned mappings
- Comprehensive documentation in README.md with lookup patterns table
- Support for projects, committees, and committee members

The function receives mapping keys as request payload and returns
corresponding values from NATS KV store, enabling efficient lookups
across the sync helper ecosystem.

🤖 Generated with [GitHub Copilot](https://github.com/features/copilot) (via Zed)

Signed-off-by: Eric Searcy <[email protected]>
@emsearcy emsearcy requested a review from a team as a code owner January 27, 2026 19:29
Copilot AI review requested due to automatic review settings January 27, 2026 19:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a NATS request/reply function (lfx.lookup_v1_mapping) that enables bidirectional lookup of v1↔v2 ID mappings for projects, committees, and committee members. The implementation adds a scalable queue subscription handler that queries the existing v1-mappings NATS KV bucket and returns the mapped value, empty string for not found/deleted cases, or error messages for failures.

Changes:

  • Added NATS queue subscription for the lfx.lookup_v1_mapping subject with scalable request handling
  • Implemented lookup handler with proper error handling, tombstone support, and consistent logging
  • Documented the API with comprehensive lookup pattern tables and response format specifications

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
cmd/lfx-v1-sync-helper/main.go Added constants for queue and subject names, and registered the QueueSubscribe handler for the lookup function
cmd/lfx-v1-sync-helper/lookup_handler.go New handler implementing bidirectional mapping lookups with error handling and tombstone support
README.md Added comprehensive NATS API documentation including request/reply format, lookup patterns table, and error handling guide

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

emsearcy and others added 2 commits January 27, 2026 11:34
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Eric Searcy <[email protected]>
Copy link

@bramwelt bramwelt left a comment

Choose a reason for hiding this comment

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

Overall this looks good. There's two CI issues I see from Megalinter:

  1. Missing package comment
  2. stdlib security vulnerability: This appears to be an issue with megalinter, as we have Golang set to 1.25.6 in the go.mod file.

The first is a simple fix - I can approve once that's added. The second is unrelated and can be address in a separate PR (may take some fighting with megalinter).

@emsearcy
Copy link
Contributor Author

emsearcy commented Jan 27, 2026

Thanks for the review—PTAL again.

(Yeah, I also tried bumping the Megalinter release (this one is pinned) and it still didn't help.)

edited to say - I just realized my push hadn't gone through yet when I requested the review, but the commit is there now (366a48c) for the missing package comment

@emsearcy emsearcy requested a review from bramwelt January 27, 2026 20:55
Adds the standard package comment 'The lfx-v1-sync-helper service.'
to maintain consistency with other files in the project.

🤖 Generated with [GitHub Copilot](https://github.com/features/copilot) (via Zed)

Signed-off-by: Eric Searcy <[email protected]>
@emsearcy
Copy link
Contributor Author

and now grype isn't complaining about stdlib, either. 🤷

@emsearcy emsearcy merged commit 1ca1580 into main Jan 28, 2026
3 checks passed
@emsearcy emsearcy deleted the feature/LFXV2-1011-nats-lookup-function branch January 28, 2026 00:05
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.

4 participants