Skip to content

fix: get latest key version ID from DB for system events#232

Open
minh-nghia wants to merge 1 commit intomainfrom
fix/system-rotate-event-get-version-id-from-db
Open

fix: get latest key version ID from DB for system events#232
minh-nghia wants to merge 1 commit intomainfrom
fix/system-rotate-event-get-version-id-from-db

Conversation

@minh-nghia
Copy link
Copy Markdown
Contributor

@minh-nghia minh-nghia commented Apr 10, 2026

What this PR does / why we need it:
Event reconciler has no access to managers and its logic to derive provider config, so calling plugin's GetKey - which requires authenticating to key provider to update key metadata - is not possible.
This PR simplifies it by getting the version ID from the DB.

Summary by CodeRabbit

  • Refactor

    • Updated internal key version information retrieval to source from database records instead of plugin queries.
  • Tests

    • Modified test setup to validate key version data originates from database persistence.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8f079325-a6d8-46a8-9a8e-a252f42c055e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This change refactors the key-version information retrieval flow from plugin-based to database-based. A new helper function getNewestKeyVersionNativeID queries the database for the newest key version record by creation timestamp. The fetchAndPopulateVersionInfo method is updated to call this new helper instead of invoking the key management plugin's GetKey method. The test TestVersionInfoPropagation is modified to persist key-version metadata directly to the database via model.KeyVersion rows rather than configuring plugin handlers. Version identifier population is now sourced from database records, with graceful handling for missing version records.

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: retrieving the latest key version ID from the database instead of the plugin, which is the core fix across all modified files.

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


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.

@push-tags-from-workflow push-tags-from-workflow bot added bug Something isn't working tests labels Apr 10, 2026
@minh-nghia
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@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: 2

🧹 Nitpick comments (1)
internal/event-processor/reconciler_test.go (1)

802-810: Drive the freshness regression through SYSTEM_KEY_ROTATE.

This subtest still proves the refreshed version on SYSTEM_SWITCH, but the reported bug is in SYSTEM_KEY_ROTATE. Since rotate has its own key-ID validation/selection path, I’d run this assertion with JobTypeSystemKeyRotate and KeyIDFrom == KeyIDTo so the exact failing flow is covered end-to-end.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c81fc228-828b-46d3-9e12-b8f7175b3829

📥 Commits

Reviewing files that changed from the base of the PR and between 5fbde21 and 957d963.

📒 Files selected for processing (3)
  • internal/event-processor/reconciler_test.go
  • internal/event-processor/repo.go
  • internal/event-processor/resolvers.go

@minh-nghia minh-nghia force-pushed the fix/system-rotate-event-get-version-id-from-db branch from 957d963 to f4072c4 Compare April 10, 2026 13:13
@minh-nghia minh-nghia changed the title fix: get latest key version ID from DB for system rotate event fix: get latest key version ID from DB for system events Apr 10, 2026
@minh-nghia minh-nghia force-pushed the fix/system-rotate-event-get-version-id-from-db branch from f4072c4 to a89f8c7 Compare April 10, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants