Skip to content

remove go-bits/easypg - #1123

Open
majewsky wants to merge 1 commit into
cobaltcore-dev:mainfrom
majewsky:remove-easypg
Open

remove go-bits/easypg#1123
majewsky wants to merge 1 commit into
cobaltcore-dev:mainfrom
majewsky:remove-easypg

Conversation

@majewsky

@majewsky majewsky commented Aug 5, 2026

Copy link
Copy Markdown

I am replacing go-bits/easypg with a clean-room reimplementation, gg/pgruntime, that features several improvements over the original API (listed e.g. in sapcc/keppel#766). None of those are really relevant for you since Cortex uses barely anything from easypg, but since I would like to get rid of go-bits/easypg eventually, this replaces your usage of the API with the equivalent API from gg/pgruntime.

If you will allow me a side note (which is not relevant for the scope of this PR), I had to chuckle when I saw that you are using sqlite for your unit tests. I did the same in Limes and Castellum all those years ago, until I finally had enough of having to deal with two separate database dialects, and realized that spawning a PostgreSQL server is barely any slower, and in fact can make CI faster because it removes the compile time for the go-sqlite CGo stuff. If you are interested in getting rid of some useless code paths, have a look at https://pkg.go.dev/go.xyrillian.de/gg/pgruntime#WithTestDB. (You will also need to patch your Makefile and GitHub Actions workflows to install PostgreSQL etc.; you can find what to do by grepping for if sr.UsesPostgres in the go-makefile-maker source code.)

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d08f54e9-ce66-49f3-bd30-d134f6531674

📥 Commits

Reviewing files that changed from the base of the PR and between 2f0d3ab and f6f3a7b.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod
🚧 Files skipped from review as they are similar to previous changes (1)
  • go.mod

📝 Walkthrough

Walkthrough

The PR updates go.xyrillian.de/gg to v1.13.3 and replaces easypg URL construction with pgruntime for production and test PostgreSQL connections.

Changes

PostgreSQL URL migration

Layer / File(s) Summary
Production URL builder
go.mod, internal/knowledge/db/db.go
Updates go.xyrillian.de/gg to v1.13.3 and adds the MySQL driver dependency. FromSecretRef now uses pgruntime.ConnectionTarget and IntoURL with the existing connection fields, application name, and SSL setting.
Test URL builder
internal/knowledge/db/testing/env.go
Builds PostgreSQL test URLs through pgruntime.ConnectionTarget and IntoURL. SQLite behavior remains unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: auhlig

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the replacement of go-bits/easypg with gg/pgruntime and the intended dependency removal.
Title check ✅ Passed The title clearly and concisely identifies the main change: removing go-bits/easypg.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/knowledge/db/db.go (1)

80-88: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Preserve the old application_name behavior on new PostgreSQL URIs.

easypg.URLFrom previously set application_name, but pgruntime.ConnectionTarget.IntoURL() only merges ConnectionOptions and ExtraConnectionOptions; it does not add it automatically. The production and PostgreSQL-container targets now produce URLs without that session metadata.

  • internal/knowledge/db/db.go#L80-L88: carry the old application name into ExtraConnectionOptions or add an equivalent explicit option for production connections.
  • internal/knowledge/db/testing/env.go#L31-L39: preserve the same option so the test path stays consistent unless the difference is intentional.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/knowledge/db/db.go` around lines 80 - 88, The PostgreSQL targets no
longer preserve the previous application_name session metadata. Update the
ConnectionTarget setup in internal/knowledge/db/db.go:80-88 to add the legacy
application name through ExtraConnectionOptions or an equivalent explicit
connection option, and apply the same change in
internal/knowledge/db/testing/env.go:31-39 so production and test connections
remain consistent.

Source: MCP tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/knowledge/db/db.go`:
- Around line 80-88: The PostgreSQL targets no longer preserve the previous
application_name session metadata. Update the ConnectionTarget setup in
internal/knowledge/db/db.go:80-88 to add the legacy application name through
ExtraConnectionOptions or an equivalent explicit connection option, and apply
the same change in internal/knowledge/db/testing/env.go:31-39 so production and
test connections remain consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 209ad27a-c2fa-4f20-99e0-10de621a87c9

📥 Commits

Reviewing files that changed from the base of the PR and between a9532c8 and 14747ec.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • go.mod
  • internal/knowledge/db/db.go
  • internal/knowledge/db/testing/env.go

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@go.mod`:
- Line 13: Inspect the module graph and repository imports for any remaining use
of github.com/sapcc/go-bits; if none remain, remove its go.mod requirement and
update go.sum accordingly, while preserving the existing go.xyrillian.de/gg
dependency and any transitively required entries.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b46c5de9-9b64-431c-b310-5268e1cec0de

📥 Commits

Reviewing files that changed from the base of the PR and between a9532c8 and 2f0d3ab.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • go.mod
  • internal/knowledge/db/db.go
  • internal/knowledge/db/testing/env.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/knowledge/db/db.go
  • internal/knowledge/db/testing/env.go

Comment thread go.mod
I am replacing go-bits/easypg with a clean-room reimplementation,
gg/pgruntime, taht features several improvements over the original API
(listed e.g. in [1]). None of those are really relevant for you since
Cortex uses barely anything from easypg, but since I would like to get
rid of go-bits/easypg eventually, this replaces your usage of the API
with the equivalent API from gg/pgruntime.

[1]: sapcc/keppel#766

Signed-off-by: Stefan Majewsky <stefan.majewsky@sap.com>
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.

1 participant