Skip to content

Conversation

@isasmendiagus
Copy link
Contributor

@isasmendiagus isasmendiagus commented Jan 27, 2026

Summary

  • Add database version info (schema_version, created_at) to the StatusResponse across all component service endpoints
  • Add server version to the StatusResponse
  • When the db_version table is not available (e.g., older Sqlite databases), the db field is omitted from the response

Dependencies

This PR depends on the following PRs being merged and tagged with their next minor version:

Summary by CodeRabbit

  • New Features

    • API status messages now include server and database version metadata; the server logs database version at startup when available.
  • Tests

    • Automated tests updated to expect and validate version metadata in responses.
  • Chores

    • Dependency updates and related adjustments.

✏️ Tip: You can customize this high-level summary in your review settings.

@isasmendiagus isasmendiagus requested a review from eeisegn January 27, 2026 17:44
@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

The PR makes the component service version-aware: server initialization now accepts a version string, service responses are enriched with DB and server version metadata, and DB version is read via a new models dependency.

Changes

Cohort / File(s) Summary
Dependency Management
go.mod
Added github.com/scanoss/go-models v0.3.0; updated github.com/scanoss/go-grpc-helper and github.com/scanoss/papi versions.
Server Initialization
pkg/cmd/server.go
Import gomodels; log DB version at startup; call NewComponentServer(db, cfg, strings.TrimSpace(version)).
Service Implementation
pkg/service/component_service.go
componentServer now stores version string and dbVersionModel *gomodels.DBVersionModel; NewComponentServer signature adds version string; added getDBVersion(); all responses (errors and success) are wrapped/enriched with StatusResponse containing Db and Server metadata.
Service Tests
pkg/service/component_service_test.go
Updated NewComponentServer calls to include "test-version" and adjusted expected Status fields to include Server{Version: "test-version"}.

Sequence Diagram

sequenceDiagram
    participant Client
    participant ComponentServer as Component Server
    participant Database
    Client->>ComponentServer: Request (SearchComponents / GetVersions)
    activate ComponentServer
    ComponentServer->>Database: Query component data
    Database-->>ComponentServer: Component data
    ComponentServer->>Database: getDBVersion()
    Database-->>ComponentServer: DB schema/version
    Note over ComponentServer: Enrich response with Server.version<br/>and Db.version
    ComponentServer-->>Client: StatusResponse { Data, Status, Db{version}, Server{version} }
    deactivate ComponentServer
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped in to add a version sign,
DB hums its number, server says "mine!"
Responses now wear tags so neat,
Metadata on every beat.
Hooray — small hops, a tidy feat! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately describes the main change: adding database version information to status responses across the component service.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@go.mod`:
- Around line 13-16: The build is failing because go.sum is missing checksums
for the newly added modules (github.com/scanoss/go-grpc-helper,
github.com/scanoss/go-models, github.com/scanoss/go-purl-helper,
github.com/scanoss/papi); run `go mod tidy` in the module root to download and
verify those dependencies and regenerate go.sum, then commit the updated go.sum
so CI can pass.
🧹 Nitpick comments (1)
pkg/service/component_service.go (1)

175-186: Consider passing the request context for better observability.

Using context.Background() loses request tracing and cancellation signals. For consistency with observability practices and to allow the DB query to be cancelled if the request is cancelled, consider passing the context from the caller.

♻️ Suggested refactor
-func (d componentServer) getDBVersion() *common.StatusResponse_DB {
-	dbVersion, err := d.dbVersionModel.GetCurrentVersion(context.Background())
+func (d componentServer) getDBVersion(ctx context.Context) *common.StatusResponse_DB {
+	dbVersion, err := d.dbVersionModel.GetCurrentVersion(ctx)
 	if err != nil || len(dbVersion.SchemaVersion) == 0 {
 		return nil
 	}
 	return &common.StatusResponse_DB{
 		SchemaVersion: dbVersion.SchemaVersion,
 		CreatedAt:     dbVersion.CreatedAt,
 	}
 }

Then update all call sites to pass ctx:

status.Db = d.getDBVersion(ctx)

Comment on lines +13 to +16
github.com/scanoss/go-grpc-helper v0.11.0
github.com/scanoss/go-models v0.3.0
github.com/scanoss/go-purl-helper v0.2.1
github.com/scanoss/papi v0.21.0
github.com/scanoss/papi v0.28.0
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Run go mod tidy to fix the build failure.

The pipeline is failing because the go.sum file is missing entries for the newly added dependencies. Run go mod tidy to regenerate the go.sum file with all required checksums.

🤖 Prompt for AI Agents
In `@go.mod` around lines 13 - 16, The build is failing because go.sum is missing
checksums for the newly added modules (github.com/scanoss/go-grpc-helper,
github.com/scanoss/go-models, github.com/scanoss/go-purl-helper,
github.com/scanoss/papi); run `go mod tidy` in the module root to download and
verify those dependencies and regenerate go.sum, then commit the updated go.sum
so CI can pass.

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