Skip to content

Close all limiters correctly in vault gateway handler#22825

Open
prashantkumar1982 wants to merge 2 commits into
developfrom
fix/vault-handler-limiter-close
Open

Close all limiters correctly in vault gateway handler#22825
prashantkumar1982 wants to merge 2 commits into
developfrom
fix/vault-handler-limiter-close

Conversation

@prashantkumar1982

Copy link
Copy Markdown
Contributor

No description provided.

@prashantkumar1982 prashantkumar1982 changed the title Close all limiters correctly Close all limiters correctly in vault gateway handler Jun 11, 2026
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

✅ No conflicts with other open PRs targeting develop

@github-actions

Copy link
Copy Markdown
Contributor

I see you updated files related to core. Please run make gocs in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

@trunk-io

trunk-io Bot commented Jun 11, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@prashantkumar1982 prashantkumar1982 marked this pull request as ready for review June 12, 2026 04:04
@prashantkumar1982 prashantkumar1982 requested review from a team as code owners June 12, 2026 04:04
@cl-sonarqube-production

Copy link
Copy Markdown

func newTestRequestValidatorWithFactoryLimiters(t *testing.T) *RequestValidator {
t.Helper()

factory := limits.Factory{Settings: cresettings.DefaultGetter}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are you using this getter? The logger could be helpful though:

Suggested change
factory := limits.Factory{Settings: cresettings.DefaultGetter}
factory := limits.Factory{Logger: logger.Test(t)}


func assertBoundLimiterStopped[N limits.Number](t *testing.T, limiter limits.BoundLimiter[N], amount N) {
t.Helper()
err := limiter.Check(context.Background(), amount)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
err := limiter.Check(context.Background(), amount)
err := limiter.Check(t.Context(), amount)

func assertBoundLimiterStopped[N limits.Number](t *testing.T, limiter limits.BoundLimiter[N], amount N) {
t.Helper()
err := limiter.Check(context.Background(), amount)
require.Error(t, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This needs to check the type of the error via require.ErrorIs since other kinds of errors may occur

MaxIdentifierNamespaceLengthLimiter limits.BoundLimiter[pkgconfig.Size]
}

func (r *RequestValidator) Close() error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We didn't have a Close function here because plugin passes in it's own Limiters and closes them itself. My validation/auth refactor cleans this up and introduces a Close function. I'll have a PR for it later today

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The issue was that the gateway handler wasn't closing these.
So we need to handle the cleanups from here: core/services/gateway/handlers/vault/handler.go

If your PR will fix it, happy to close this one.

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.

3 participants