Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return InvalidArgument for invalid input entries #5506

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sorindumitru
Copy link
Contributor

  • Commit conforms to CONTRIBUTING.md?
  • Proper tests/regressions included?
  • Documentation updated?

Affected functionality
Returned error codes for BatchCreateEntry/BatchUpdateEntry

Description of change
Return better error codes in case of invalid entries so users can differentiate between entries that can be retried and those that can't

Which issue this PR fixes
fixes #5444

Signed-off-by: Sorin Dumitru <sdumitru@bloomberg.net>
@@ -658,6 +755,13 @@ func (s *Service) updateEntry(ctx context.Context, e *types.Entry, inputMask *ty
Hint: inputMask.Hint,
}
}

if err := validateRegistrationEntryForUpdate(convEntry, mask); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

An alternative to this would be to add all the validations here in

func ProtoToRegistrationEntryWithMask(ctx context.Context, td spiffeid.TrustDomain, e *types.Entry, mask *types.EntryMask) (_ *common.RegistrationEntry, err error) {
but I wasn't sure that's where the maintainers would want to add these checks.

That function already does some validations, but mostly as a necessity of handling errors. It would also simplify things a bit. Let me know if that's better and I can change this.

@sorindumitru sorindumitru force-pushed the entry-errors branch 2 times, most recently from 59afb34 to a88df74 Compare September 20, 2024 07:08
Signed-off-by: Sorin Dumitru <sdumitru@bloomberg.net>
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.

spire-server: Better status codes from BatchCreateEntry API
2 participants