[LFXV2-947] Add NATS message handler for getting parent project UID#38
[LFXV2-947] Add NATS message handler for getting parent project UID#38
Conversation
Adds a new NATS message handler that retrieves a project's parent UID given a project UID. This enables other services to navigate project hierarchies by querying parent relationships. Changes: - Add ProjectGetParentUIDSubject constant (lfx.projects-api.get_parent_uid) - Implement HandleProjectGetParentUID handler using existing attribute helper - Register handler in handlers map and NATS subscription list - Add comprehensive unit tests with 5 test cases covering success and error scenarios - Update README.md to document the new NATS message handler - Improve error logging in GetProjectBase and GetProjectBaseWithRevision to show actual underlying errors instead of just "internal error" The handler follows the same pattern as other attribute handlers (get_name, get_slug, get_logo) and returns the parent_uid field from a project. If a project has no parent (root project), an empty string is returned. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Andres Tobon <andrest2455@gmail.com>
WalkthroughAdds a new NATS subject and handler to return a project's parent UID; registers the subject for subscription, adds a constant, augments repository error logging, updates tests (including a duplicated test function), and bumps the Helm chart version. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant NATS as NATS<br/>'lfx.projects-api.get_parent_uid'
participant Handler as ProjectsService<br/>HandleProjectGetParentUID
participant Repo as KV Repository<br/>GetProjectBase
Client->>NATS: Publish message (project_uid)
NATS->>Handler: Deliver message
Handler->>Handler: Validate project_uid
rect rgb(230,240,255)
Handler->>Repo: GetProjectBase(project_uid)
alt KV Success
Repo-->>Handler: Project data (includes parent_uid)
Handler->>Handler: Extract parent_uid
Handler-->>NATS: Respond with parent_uid JSON
else Not found
Repo-->>Handler: KeyNotFound
Handler-->>NATS: Respond 404
else KV error
Repo-->>Handler: Error (logged)
Handler-->>NATS: Respond internal error
end
end
NATS-->>Client: Response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
⛔ Files ignored due to path filters (14)
📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (1)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR adds a new NATS message handler to retrieve a project's parent UID, enabling other services to navigate project hierarchies. The implementation follows the established pattern of existing attribute handlers (get_name, get_slug, get_logo).
- Added NATS subject handler
lfx.projects-api.get_parent_uidfor querying parent project UIDs - Implemented comprehensive test coverage including edge cases (empty parent, not found, invalid UUID)
- Enhanced error logging in repository methods to expose underlying errors instead of generic messages
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/constants/nats.go | Added ProjectGetParentUIDSubject constant for the new NATS subject |
| internal/service/project_handlers.go | Implemented HandleProjectGetParentUID handler using the shared attribute helper pattern |
| cmd/project-api/main.go | Registered the new handler in the NATS subscription list |
| internal/service/project_handlers_test.go | Added comprehensive unit tests for the new handler covering success and error scenarios |
| internal/infrastructure/nats/repository.go | Enhanced error logging in GetProjectBase and GetProjectBaseWithRevision to show underlying errors |
| README.md | Updated documentation to include the new NATS message handler |
| charts/lfx-v2-project-service/Chart.yaml | Bumped chart version from 0.5.3 to 0.5.4 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Updates the Makefile to pin the Goa framework version from v3 (latest) to v3.22.6 to ensure consistent code generation and build compatibility across development environments. Changes: - Pin GOA_VERSION to v3.22.6 in Makefile - Update goa install command to use the pinned version - Regenerate API code with goa v3.22.6 This ensures all developers and CI/CD pipelines use the same version of Goa, preventing code generation inconsistencies. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Andres Tobon <andrest2455@gmail.com>
|
|
||
| // HandleProjectGetParentUID is the message handler for the project-get-parent-uid subject. | ||
| func (s *ProjectsService) HandleProjectGetParentUID(ctx context.Context, msg domain.Message) ([]byte, error) { | ||
| return s.handleProjectGetAttribute(ctx, msg, constants.ProjectGetParentUIDSubject, "parent_uid") |
There was a problem hiding this comment.
This is very handy!
Summary
lfx.projects-api.get_parent_uidto retrieve a project's parent UIDChanges
Core Implementation
ProjectGetParentUIDSubjectconstant inpkg/constants/nats.goHandleProjectGetParentUIDhandler ininternal/service/project_handlers.gocmd/project-api/main.goTesting
internal/service/project_handlers_test.goDocumentation & Improvements
README.mdto document the new NATS message handlerGetProjectBaseandGetProjectBaseWithRevisionto show actual underlying errors instead of generic "internal error"Ticket
https://linuxfoundation.atlassian.net/browse/LFXV2-947
🤖 Generated with Claude Code