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

fix: error handling on identity import #3520

Merged
merged 4 commits into from
Sep 21, 2023
Merged

Conversation

zepatrik
Copy link
Member

@zepatrik zepatrik commented Sep 19, 2023

When importing identities without any traits, or with malformed traits, 500s are returned. This improves the error handling and messaging.
Per default, missing traits now get rewritten to an empty object. Otherwise sjson would produce invalid JSON, and JSON parse errors would be returned even though the payload was valid.

@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

Merging #3520 (6043b68) into master (32d8306) will increase coverage by 0.13%.
The diff coverage is 76.92%.

❗ Current head 6043b68 differs from pull request most recent head 9372466. Consider uploading reports for the commit 9372466 to get more accurate results

@@            Coverage Diff             @@
##           master    #3520      +/-   ##
==========================================
+ Coverage   78.17%   78.31%   +0.13%     
==========================================
  Files         341      341              
  Lines       22754    22679      -75     
==========================================
- Hits        17789    17761      -28     
+ Misses       3626     3591      -35     
+ Partials     1339     1327      -12     
Files Changed Coverage Δ
schema/validator.go 85.71% <50.00%> (-6.29%) ⬇️
identity/validator.go 78.57% <83.33%> (+3.57%) ⬆️
identity/handler.go 85.32% <100.00%> (ø)
identity/manager.go 75.22% <100.00%> (+0.11%) ⬆️

... and 19 files with indirect coverage changes

Comment on lines +54 to +56
if len(i.Traits) == 0 {
i.Traits = []byte(`{}`)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the fix. Without, sjson.SetRawBytes below would produce invalid JSON, although the payload is valid JSON.

@aeneasr aeneasr merged commit 83bfb2d into master Sep 21, 2023
29 checks passed
@aeneasr aeneasr deleted the fix/empty-traits-import branch September 21, 2023 06:34
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.

2 participants