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

When oneOf/anyOf fails to decode, include all the individual sub-errors as well #275

Closed
czechboy0 opened this issue Sep 15, 2023 · 0 comments · Fixed by #350
Closed

When oneOf/anyOf fails to decode, include all the individual sub-errors as well #275

czechboy0 opened this issue Sep 15, 2023 · 0 comments · Fixed by #350
Assignees
Labels
area/generator Affects: plugin, CLI, config file. area/runtime Affects: the runtime library. kind/enhancement Improvements to existing feature. size/S Small task. (A couple of hours of work.)
Milestone

Comments

@czechboy0
Copy link
Contributor

czechboy0 commented Sep 15, 2023

When oneOf/anyOf fails to decode, include all the individual sub-errors as well.

Otherwise it's difficult to debug why none of the payloads decoded successfully.

@czechboy0 czechboy0 added area/generator Affects: plugin, CLI, config file. area/runtime Affects: the runtime library. kind/enhancement Improvements to existing feature. size/S Small task. (A couple of hours of work.) labels Sep 15, 2023
@czechboy0 czechboy0 added this to the 1.0 milestone Sep 15, 2023
@czechboy0 czechboy0 changed the title When oneOf fails to decode, include all the individual sub-errors as well When oneOf/anyOf fails to decode, include all the individual sub-errors as well Sep 15, 2023
@czechboy0 czechboy0 added the status/blocked Waiting for another issue. label Sep 15, 2023
@czechboy0 czechboy0 removed the status/blocked Waiting for another issue. label Oct 11, 2023
@czechboy0 czechboy0 self-assigned this Oct 27, 2023
czechboy0 added a commit to apple/swift-openapi-runtime that referenced this issue Oct 30, 2023
[Runtime] Include partial errors in oneOf/anyOf decoding errors

### Motivation

The runtime changes to address apple/swift-openapi-generator#275.

This makes debugging of decoding of oneOf/anyOf much easier, as the individual errors aren't dropped on the floor anymore.

### Modifications

Added SPI that allows the generated code to collect and report partial errors when a oneOf/anyOf fails to decode (that includes trying multiple subschemas, which themselves emit errors when they're not the right match).

### Result

Easier debugging of oneOf/anyOf decoding issues.

### Test Plan

Tested manually as part of the generator changes, we don't generally test exact error strings.


Reviewed by: simonjbeaumont

Builds:
     ✔︎ pull request validation (5.10) - Build finished. 
     ✔︎ pull request validation (5.8) - Build finished. 
     ✔︎ pull request validation (5.9) - Build finished. 
     ✔︎ pull request validation (docc test) - Build finished. 
     ✔︎ pull request validation (integration test) - Build finished. 
     ✔︎ pull request validation (nightly) - Build finished. 
     ✔︎ pull request validation (soundness) - Build finished. 
     ✖︎ pull request validation (api breakage) - Build finished. 

#66
czechboy0 added a commit that referenced this issue Oct 30, 2023
[Generator] Include partial errors in oneOf/anyOf decoding errors

### Motivation

Fixes #275.

Depends on apple/swift-openapi-runtime#66.

### Modifications

Adapt the generator to emit code that collects individual errors during oneOf/anyOf decoding and includes them in the final error.

### Result

Easier debugging of oneOf/anyOf decoding issues.

### Test Plan

Adapted tests and verified that the errors look better now and include the partial errors.


Reviewed by: simonjbeaumont

Builds:
     ✔︎ pull request validation (5.10) - Build finished. 
     ✔︎ pull request validation (5.8) - Build finished. 
     ✔︎ pull request validation (5.9) - Build finished. 
     ✔︎ pull request validation (compatibility test) - Build finished. 
     ✔︎ pull request validation (docc test) - Build finished. 
     ✔︎ pull request validation (integration test) - Build finished. 
     ✔︎ pull request validation (nightly) - Build finished. 
     ✔︎ pull request validation (soundness) - Build finished. 

#350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/generator Affects: plugin, CLI, config file. area/runtime Affects: the runtime library. kind/enhancement Improvements to existing feature. size/S Small task. (A couple of hours of work.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant