Skip to content

Conversation

@tstirrat15
Copy link
Contributor

Description

We got a couple of reports of this. The errors in question were PermissionDenied errors, but we were effectively swallowing them because I missed returning the err when I refactored this logic in #543.

Changes

Will annotate

Testing

Review. See that tests still pass.

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

Comment on lines +411 to +413
if err != nil {
return 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.

This was the substantive change. In #543 I refactored things to use takeBackup, which meant that the returns that moved into takeBackup no longer interrupted execution. I missed returning err here because I assumed that it was at the bottom; ineffassign didn't yell because of the defer blocks that take a pointer to err.

Comment on lines +54 to +58
cmdErr := f(cmd, args)
for _, handler := range errorHandlers {
cmdErr = handler(cmdErr)
}
return cmdErr
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing this to allow us to add other handlers

if code != codes.PermissionDenied {
return err
}
return fmt.Errorf("%w: ensure that the token used for this call has all requisite permissions")
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 should help guide users to setting the appropriate permissions

Comment on lines 284 to 290
runErrs := make(chan error, 1)
go func() {
require.NoError(t, srv.Run(ctx))
err := srv.Run(ctx)
runErrs <- err
}()
err := <-runErrs
require.NoError(t, 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.

These two refactors are testifyrequire lint fixes that I did as drive-bys. We don't have that linter enabled yet. I'd like to do that soon.

@tstirrat15 tstirrat15 force-pushed the fix-backup-error-propagation branch 2 times, most recently from 0286f54 to 2b0c0cd Compare October 21, 2025 18:16
Comment on lines +416 to +419
// NOTE: we return err here because there's cleanup being done
// in the `defer` blocks that will modify the `err` if cleanup
// fails
return 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.

This is also a meaningful change.

@tstirrat15 tstirrat15 force-pushed the fix-backup-error-propagation branch from 2b0c0cd to 12757c8 Compare October 21, 2025 18:33
@codecov-commenter
Copy link

codecov-commenter commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 19.04762% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.23%. Comparing base (7ed5ab0) to head (e89fc81).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
internal/cmd/backup.go 19.04% 16 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #568      +/-   ##
==========================================
+ Coverage   39.28%   41.23%   +1.95%     
==========================================
  Files          37       37              
  Lines        5448     5818     +370     
==========================================
+ Hits         2140     2399     +259     
- Misses       3063     3162      +99     
- Partials      245      257      +12     

☔ 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.

@tstirrat15 tstirrat15 force-pushed the fix-backup-error-propagation branch from 12757c8 to 7837fd3 Compare October 21, 2025 18:43
Co-authored-by: Maria Ines Parnisari <[email protected]>
Copy link
Contributor

@miparnisari miparnisari left a comment

Choose a reason for hiding this comment

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

old

$ zed backup create
⠋ processing backup (0/-, 0 relationship/hr) [0s] 
1:20PM INF finished backup elapsed=0s filtered=0 processed=0 throughput=0

vs new

./zed backup create
1:19PM WRN not calling a released version of SpiceDB version=v1.46.1-0.20251020215342-0ecaf138fce1+enterprise.devel.(devel)
⠋ processing backup (0/-, 0 relationship/hr) [0s] 
1:19PM INF backup failed elapsed=0s filtered=0 processed=0 throughput=0
1:19PM ERR terminated with errors error="error receiving relationships: rpc error: code = PermissionDenied desc = unauthorized operation: ensure that the token used for this call has all requisite permissions"

LGTM 👍 please open an issue to refactor this code and write unit tests more easily

@tstirrat15
Copy link
Contributor Author

Tracked in #569

@tstirrat15 tstirrat15 merged commit 2dad959 into main Oct 21, 2025
11 checks passed
@tstirrat15 tstirrat15 deleted the fix-backup-error-propagation branch October 21, 2025 21:50
@github-actions github-actions bot locked and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants