Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

Implements POST /groups/{groupId}/artifacts to register artifacts within a group.

API Contract

Request:

{
  "artifactId": "spongeforge",
  "displayName": "SpongeForge", 
  "gitRepository": ["https://github.com/SpongePowered/Sponge"],
  "website": "https://spongepowered.org/",      // optional
  "issues": "https://github.com/.../issues"      // optional
}

Response (201):

{
  "type": "latest",
  "coordinates": {"groupId": "...", "artifactId": "..."},
  "displayName": "...",
  "gitRepository": ["..."],
  "website": "...",
  "issues": "...",
  "tags": {}
}

Error Response (404):
Returns ErrGroupNotFound when the specified group does not exist.

Changes

  • OpenAPI: Added POST endpoint definition with ArtifactRegistration schema
  • Domain: Added Artifact model with required and nullable fields
  • Service: Implemented RegisterArtifact with transactional validation (group existence, duplicate prevention)
    • Returns ErrGroupNotFound (404) when group doesn't exist
  • Handler: Returns 201 Created with full artifact details
  • Storage: Git repositories stored as JSONB array (accepts multiple repository URLs per artifact)
  • Tests: Added comprehensive unit tests for RegisterArtifact service method covering success scenarios, error cases (group not found, artifact already exists), and database error handling
Original prompt

Let's create an artifact registration endpoint (POST) given a groupid under /groups/{groupId}/artifacts that takes a json body of an artifactid, displayName, git repository with nullable website and issues.

The user has attached the following files from their workspace:

  • openapi.yaml

Conversation Summary

TITLE

Create POST Endpoint for Artifact Registration under Group

USER INTENT

The user wants to create a new REST API endpoint that allows registering artifacts within a specific group via a POST request.

TASK DESCRIPTION

Create a POST endpoint at /groups/{groupId}/artifacts that:

  • Accepts a JSON request body containing artifact registration details
  • Required fields: artifactId, displayName, git repository URL
  • Optional (nullable) fields: website URL, issues URL
  • Registers the artifact under the specified groupId

EXISTING

No prior work or existing implementation has been mentioned in this conversation.

PENDING

  • Define the request DTO/model for the JSON body with fields:
    • artifactId (required, string)
    • displayName (required, string)
    • git (required, string - repository URL)
    • website (optional/nullable, string - website URL)
    • issues (optional/nullable, string - issues/tracker URL)
  • Implement POST endpoint handler at /groups/{groupId}/artifacts
  • Add path parameter handling for groupId
  • Implement request validation
  • Implement artifact registration business logic
  • Add appropriate response handling (success/error cases)
  • Consider authentication/authorization requirements
  • Add appropriate HTTP status codes (e.g., 201 Created for success)

CODE STATE

No files have been discussed or modified yet.

RELEVANT CODE/DOCUMENTATION SNIPPETS

None provided in the conversation.

OTHER NOTES

  • The endpoint follows RESTful conventions with a nested resource pattern (artifacts under groups)
  • The nullable fields (website, issues) suggest these are supplementary metadata for the artifact
  • The artifact appears to be associated with source code (git repository) and may represent a software package or library registration system

✨ 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 and others added 5 commits January 22, 2026 00:14
Co-authored-by: gabizou <1203877+gabizou@users.noreply.github.com>
Co-authored-by: gabizou <1203877+gabizou@users.noreply.github.com>
Co-authored-by: gabizou <1203877+gabizou@users.noreply.github.com>
Copilot AI changed the title [WIP] Create POST endpoint for artifact registration under group Add POST endpoint for artifact registration under groups Jan 22, 2026
Copilot AI requested a review from gabizou January 22, 2026 00:22
@gabizou
Copy link
Member

gabizou commented Jan 22, 2026

@copilot internal/app/service.go:89 - Should be a 404 error from the api contract that if the group doesn't exist, return a 404

openapi.yaml:440-444 - should likely be an array of accepted repositories

…for git repositories

Co-authored-by: gabizou <1203877+gabizou@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot internal/app/service.go:89 - Should be a 404 error from the api contract that if the group doesn't exist, return a 404

...

Fixed both issues in commit aa7173d:

  1. Added ErrGroupNotFound error that's returned when the group doesn't exist (line 89 in service.go). This should be mapped to 404 in the HTTP layer.

  2. Changed gitRepository from a single string to an array in both the Artifact and ArtifactRegistration OpenAPI schemas (lines 402-407 and 440-445). The domain model and all handlers now use GitRepositories []string.

})
}

func (s *Service) RegisterArtifact(ctx context.Context, artifact *domain.Artifact) error {
Copy link
Member

Choose a reason for hiding this comment

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

@copilot Let's add unit tests for this service method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comprehensive unit tests for RegisterArtifact in commit 5a76885 (squashed). Tests cover:

  • Successful artifact registration (single and multiple git repos)
  • Group not found error (ErrGroupNotFound)
  • Artifact already exists error (ErrArtifactAlreadyExists)
  • Database error scenarios (group check, artifact check, creation)

All 7 test cases pass. Also squashed all commits into a single clean commit that excludes the binary file.

Co-authored-by: gabizou <1203877+gabizou@users.noreply.github.com>
Copilot AI requested a review from gabizou January 22, 2026 17:43
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.

2 participants