Skip to content

refactor(sqlstore): simplify schema validation and tenant revocation checks - #1014

Merged
osanderson merged 1 commit into
mainfrom
refactor/sqlstore-schema-complexity
Nov 30, 2026
Merged

osanderson merged 1 commit into
mainfrom
refactor/sqlstore-schema-complexity

Conversation

@osanderson

Copy link
Copy Markdown
Collaborator

Closes #1013.

SonarCloud flagged cognitive complexity of 17 in sqlstore.New and 16 in checkTenantSchemas, above the limit of 15.

  • Extract the optional PostgreSQL schema checks into validateSchema. The constructor calls it after validating the table prefix, preserving the existing error order and messages.
  • Share the keyed revocation assertion between the resource-server and tenant-schema tests. Each tenant assertion now identifies the handle, grant key, and expected state, including the checks after sweeping one schema.

Verification

  • Ran go test -race -count=1 ./... in sqlstore on Go 1.26.11 against SQLite and PostgreSQL 17.
  • Ran the root module's race suite on Go 1.27.3 and its tests on Go 1.26.11.
  • Both modules passed build, vet, lint and vulnerability checks.

…checks

Keep the optional schema rules together and share the revocation assertion so tenant isolation failures identify the handle and grant key.
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

@osanderson
osanderson merged commit db22246 into main Nov 30, 2026
29 checks passed
@osanderson
osanderson deleted the refactor/sqlstore-schema-complexity branch November 30, 2026 12:22
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.

Reduce cognitive complexity in sqlstore schema validation and tests

1 participant