Skip to content

Migrate tags endpoints to nexus service#76

Merged
jeroenrinzema merged 7 commits intomainfrom
copilot/migrate-tags-endpoints-nexus
Dec 1, 2025
Merged

Migrate tags endpoints to nexus service#76
jeroenrinzema merged 7 commits intomainfrom
copilot/migrate-tags-endpoints-nexus

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 30, 2025

  • Simplified search parameter handling to use params.Search.ToString() directly
  • Removed escapeILIKEPattern function and its usage
  • Removed RowsAffected checks from UpdateTag and DeleteTag
  • Updated controller to handle GetTag errors properly after UpdateTag
  • Updated tests to reflect new behavior (delete is now idempotent)
  • All tests passing

Changes Made

Controller Layer (tags.go)

  • ListTags: Simplified to call params.Search.ToString() directly instead of nil checking
  • UpdateTag: Added proper error handling for GetTag when tag doesn't exist after update

Store Layer (tags.go)

  • ListTags: Removed escapeILIKEPattern call - search is used directly in ILIKE query
  • UpdateTag: Removed RowsAffected check - operation succeeds even if no rows affected
  • DeleteTag: Removed RowsAffected check - operation succeeds even if no rows affected (idempotent)
  • Removed escapeILIKEPattern function entirely
  • Removed unused strings import

Tests (tags_test.go)

  • TestDeleteTag: Updated to expect 204 for non-existing tags (idempotent behavior)
  • TestUpdateTag: Keeps 404 expectation since GetTag returns error for non-existing tags

Behavior Changes

  • Delete operation is now idempotent - deleting a non-existent tag returns 204 (success)
  • Update operation still returns 404 for non-existent tags because GetTag checks existence
  • Search no longer escapes special ILIKE pattern characters (%, _)
Original prompt

This section details on the original issue you should resolve

<issue_title>Migrate tags endpoints to nexus service</issue_title>
<issue_description>The project admin endpoints in /services/platform/src/tags/TagController.ts have to be migrated to the nexus service. Please follow the style and architecture of the nexus project and include unit tests using test containers for the newly created controller and store if needed.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Migrate tags endpoints to nexus service Migrate tags endpoints to nexus service Nov 30, 2025
Copilot AI requested a review from jeroenrinzema November 30, 2025 20:19
@jeroenrinzema jeroenrinzema requested review from Copilot and removed request for jeroenrinzema November 30, 2025 20:25
Copy link
Copy Markdown

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 migrates the core tags CRUD operations from the legacy platform service to nexus, following the established OpenAPI-first architecture. The migration adds 5 RESTful endpoints for managing tags (list, create, get, update, delete) with proper multi-tenant isolation, search functionality, and pagination support.

Key changes:

  • Defined OpenAPI specification for tag endpoints and schemas
  • Implemented store layer with SQL injection protection for search queries
  • Created controller layer with comprehensive error handling and logging
  • Added testcontainer-based integration tests covering success and error scenarios

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
services/nexus/oapi/resources.yml Defines 5 tag endpoints with OpenAPI specs including Tag, CreateTag, UpdateTag schemas and TagListResponse
services/nexus/oapi/resources_gen.go Auto-generated Go types and client methods from OpenAPI specification
services/nexus/internal/store/tags.go Store layer implementing CRUD operations with ILIKE pattern escaping and RowsAffected validation
services/nexus/internal/store/store.go Registers TagsStore in the stores collection
services/nexus/internal/http/controllers/v1/tags.go Controller handlers for all tag endpoints with structured logging
services/nexus/internal/http/controllers/v1/tags_test.go Integration tests using testcontainers covering all CRUD operations
services/nexus/internal/http/controllers/v1/controller.go Adds TagsController to main controller struct

Comment thread services/nexus/internal/http/controllers/v1/tags.go Outdated
Comment thread services/nexus/internal/store/tags.go
Comment thread services/nexus/internal/store/tags.go Outdated
Comment thread services/nexus/internal/store/tags.go
Comment thread services/nexus/internal/store/tags.go Outdated
@jeroenrinzema
Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 30, 2025

@copilot apply changes based on the comments in this thread

Applied all review comments in commit f4faf74:

  1. ✅ Removed unnecessary project existence check in CreateTag - now relies on foreign key constraint
  2. ✅ Fixed comment clarifying ILIKE pattern escaping (not SQL injection prevention - that's handled by parameterized queries)
  3. ✅ Added soft delete support with migration 1764534970_add_tags_deleted_at.up.sql
  4. ✅ Updated GetTag to filter deleted_at IS NULL
  5. ✅ Updated ListTags to filter deleted_at IS NULL
  6. ✅ Changed DeleteTag from hard delete to soft delete using SET deleted_at = NOW()

All tests passing. The updated_at timestamp is automatically handled by the set_updated_at_tags database trigger.

Copy link
Copy Markdown

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread services/nexus/internal/store/tags.go Outdated
Comment thread services/nexus/internal/store/tags.go Outdated
Comment thread services/nexus/internal/http/controllers/v1/tags.go Outdated
Comment thread services/nexus/internal/store/tags.go Outdated
Comment thread services/nexus/internal/store/tags.go Outdated
Comment thread services/nexus/internal/store/tags.go Outdated
Comment thread services/nexus/internal/store/tags.go Outdated
Copilot AI requested a review from jeroenrinzema November 30, 2025 21:33
@jeroenrinzema jeroenrinzema marked this pull request as ready for review November 30, 2025 21:57
Base automatically changed from refactor/users to main December 1, 2025 09:50
Copilot AI and others added 6 commits December 1, 2025 10:57
…ler and tests

Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
…timize database queries

Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
…ve unnecessary project check

Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
…ern comment

Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
…d checks

Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
@jeroenrinzema jeroenrinzema force-pushed the copilot/migrate-tags-endpoints-nexus branch from 6368635 to 215177e Compare December 1, 2025 09:58
@jeroenrinzema jeroenrinzema merged commit ecde46e into main Dec 1, 2025
3 checks passed
@jeroenrinzema jeroenrinzema deleted the copilot/migrate-tags-endpoints-nexus branch December 1, 2025 09:59
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.

Migrate tags endpoints to nexus service

3 participants