Skip to content

build: add new mustcallcheck analyzer and fix instances#2886

Merged
tstirrat15 merged 5 commits intomainfrom
new-mustcallcheck-analyzer
Feb 6, 2026
Merged

build: add new mustcallcheck analyzer and fix instances#2886
tstirrat15 merged 5 commits intomainfrom
new-mustcallcheck-analyzer

Conversation

@tstirrat15
Copy link
Contributor

Description

Follow-on to #2878. We realized we could write an analyzer that checks for that condition explicitly, so we did that and fixed the findings.

Changes

  • Add mustcallcheck analyzer
  • Add tests for the analyzer
  • Fix what the analyzer found

Testing

Review. See that analyzers and tests pass.

@tstirrat15 tstirrat15 requested a review from a team as a code owner February 6, 2026 15:53
@github-actions github-actions bot added area/cli Affects the command line area/schema Affects the Schema Language area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Feb 6, 2026
@tstirrat15 tstirrat15 force-pushed the new-mustcallcheck-analyzer branch from 193cb16 to c63662d Compare February 6, 2026 15:56
Copy link
Contributor Author

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

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

See comments

mapped := NewSubjectByTypeSet()
for key, subjectset := range s.byType {
ns, rel := tuple.MustSplitRelRef(key)
ns, rel, err := tuple.SplitRelRef(key)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this new function and then used it where it was appropriate.

Comment on lines +132 to +133
// RegisterCacheFlags registers flags used to configure SpiceDB's various caches.
func RegisterCacheFlags(flags *pflag.FlagSet, flagPrefix, flagDescription string, config, defaults *CacheConfig) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This probably would have been fine as an exception because the error case is hard to hit, but it also wasn't too bad to make it return an error.

Comment on lines +151 to +154
dispatcher, err := graph.NewLocalOnlyDispatcher(params)
if err != nil {
return nil, nil, err
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar here - hard to hit, but also probably not a problem.

Comment on lines +18 to +38
nameAllowList = []string{
// MustBugf returns an error in production, only panics in tests
"MustBugf",
// MustPanicf is explicitly for violating the linter when necessary
"MustPanicf",
// MustFromContext is used to grab a datastore handle out of context;
// if the datastore reference isn't available we should probably panic.
"MustFromContext",
// MustValue is used to pull ctxkey values out of context. If the value isn't
// present, it means there's probably a bug and a panic is appropriate.
"MustValue",
// MustNewInterceptorPooler comes from pgx and doesn't have an alternative
"MustNewInterceptorPooler",
// MustRequirePresharedKey is intended to be a guardrail if the preshared key isn't
// present at the callsite.
"MustRequirePresharedKey",
}
packageAllowList = []string{
// cobrautil has many Must* functions but doesn't have non-Must variants
"cobrautil",
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the list of exceptions - take a look and lemme know what you think.

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 42.18750% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.87%. Comparing base (3b519e8) to head (e3272ee).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/cmd/serve.go 25.00% 8 Missing and 4 partials ⚠️
internal/datastore/memdb/readwrite.go 33.34% 4 Missing and 2 partials ⚠️
pkg/schema/reachabilitygraph.go 25.00% 4 Missing and 2 partials ⚠️
internal/datasets/subjectsetbytype.go 25.00% 2 Missing and 1 partial ⚠️
pkg/development/devcontext.go 40.00% 2 Missing and 1 partial ⚠️
pkg/namespace/builder.go 62.50% 2 Missing and 1 partial ⚠️
pkg/tuple/strings.go 62.50% 2 Missing and 1 partial ⚠️
pkg/cmd/server/cacheconfig.go 66.67% 1 Missing ⚠️

❌ Your project status has failed because the head coverage (74.87%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2886      +/-   ##
==========================================
- Coverage   74.89%   74.87%   -0.01%     
==========================================
  Files         484      484              
  Lines       57997    58036      +39     
==========================================
+ Hits        43430    43449      +19     
- Misses      11530    11545      +15     
- Partials     3037     3042       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

"MustRequirePresharedKey",
}
packageAllowList = []string{
// cobrautil has many Must* functions but doesn't have non-Must variants
Copy link
Contributor

Choose a reason for hiding this comment

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

😭

Copy link
Contributor Author

@tstirrat15 tstirrat15 Feb 6, 2026

Choose a reason for hiding this comment

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

Yeah, but I'm also not too worried about it because they typically happen during process startup and if they panic it indicates a bug in the code rather than invalid input.

@miparnisari miparnisari changed the title New mustcallcheck analyzer build: add new mustcallcheck analyzer and fix instances Feb 6, 2026
@tstirrat15 tstirrat15 enabled auto-merge (squash) February 6, 2026 19:37
@tstirrat15 tstirrat15 force-pushed the new-mustcallcheck-analyzer branch from c63662d to e3272ee Compare February 6, 2026 19:37
@tstirrat15 tstirrat15 merged commit 7f9bd27 into main Feb 6, 2026
75 of 78 checks passed
@tstirrat15 tstirrat15 deleted the new-mustcallcheck-analyzer branch February 6, 2026 19:56
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area/cli Affects the command line area/datastore Affects the storage system area/schema Affects the Schema Language area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants