Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

feat: add error handling for application/problem+json responses #367

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

displague
Copy link
Contributor

@displague displague commented Jun 2, 2023

While the Equinix Metal API does not return this API header natively, tools such as Spotlight Prism can proxy the API and they may return this standard error content-type.

https://datatracker.ietf.org/doc/html/rfc7807

How has this been tested?

As demonstrated in https://gist.github.com/displague/27363182851f0eab4b599401f83f4b1e, errors returned with this content type are passed through as a JSON blob.

{"type":"https://stoplight.io/prism/errors#VIOLATIONS","title":"Request/Response not valid","status":500,"detail":"Your request/response is not valid and the --errors flag is set, so Prism is generating this error for you.","validation":[{"location":["response","body","plans","0","type"],"severity":"Error","code":"type","message":"Request body property plans.0.type must be string"},{"location":["response","body","plans","0","type"],"severity":"Error","code":"enum","message":"Request body property plans.0.type must be equal to one of the allowed values: standard, workload_optimized, custom"},{"location":["response","body","plans","1","specs","drives","1","type"],"severity":"Error","code":"enum","message":"Request body property plans.1.specs.drives.1.type must be equal to one of the allowed values: HDD, SSD, NVME"},{"location":["response","body","plans","1","type"],"severity":"Error","code":"type","message":"Request body property plans.1.type must be string"},{"location":["response","body","plans","1","type"],"severity":"Error","code":"enum","message":"Request body property plans.1.type must be equal to one of the allowed values: standard, workload_optimized, custom"},{"location":["response","body","plans","2","specs","drives","1","type"],"severity":"Error","code":"enum","message":"Request body property plans.2.specs.drives.1.type must be equal to one of the allowed values: HDD, SSD, NVME"},{"location":["response","body","plans","11","specs","drives","1","type"],"severity":"Error","code":"enum","message":"Request body property plans.11.specs.drives.1.type must be equal to one of the allowed values: HDD, SSD, NVME"},{"location":["response","body","plans","23","type"],"severity":"Error","code":"type","message":"Request body property plans.23.type must be string"},{"location":["response","body","plans","23","type"],"severity":"Error","code":"enum","message":"Request body property plans.23.type must be equal to one of the allowed values: standard, workload_optimized, custom"},{"location":["response","body","plans","24","type"],"severity":"Error","code":"type","message":"Request body property plans.24.type must be string"},{"location":["response","body","plans","24","type"],"severity":"Error","code":"enum","message":"Request body property plans.24.type must be equal to one of the allowed values: standard, workload_optimized, custom"},{"location":["response","body","plans","25","type"],"severity":"Error","code":"type","message":"Request body property plans.25.type must be string"},{"location":["response","body","plans","25","type"],"severity":"Error","code":"enum","message":"Request body property plans.25.type must be equal to one of the allowed values: standard, workload_optimized, custom"},{"location":["response","body","plans","26","type"],"severity":"Error","code":"type","message":"Request body property plans.26.type must be string"},{"location":["response","body","plans","26","type"],"severity":"Error","code":"enum","message":"Request body property plans.26.type must be equal to one of the allowed values: standard, workload_optimized, custom"},{"location":["response","body","plans","28","specs","drives","0","type"],"severity":"Error","code":"enum","message":"Request body property plans.28.specs.drives.0.type must be equal to one of the allowed values: HDD, SSD, NVME"},{"location":["response","body","plans","28","specs","nics","0","type"],"severity":"Error","code":"enum","message":"Request body property plans.28.specs.nics.0.type must be equal to one of the allowed values: 1Gbps, 10Gbps, 25Gbps"},{"location":["response","body","plans","29","specs","drives","0","type"],"severity":"Error","code":"enum","message":"Request body property plans.29.specs.drives.0.type must be equal to one of the allowed values: HDD, SSD, NVME"},{"location":["response","body","plans","29","specs","nics","0","type"],"severity":"Error","code":"enum","message":"Request body property plans.29.specs.nics.0.type must be equal to one of the allowed values: 1Gbps, 10Gbps, 25Gbps"},{"location":["response","body","plans","42","type"],"severity":"Error","code":"type","message":"Request body property plans.42.type must be string"},{"location":["response","body","plans","42","type"],"severity":"Error","code":"enum","message":"Request body property plans.42.type must be equal to one of the allowed values: standard, workload_optimized, custom"},{"location":["response","body","plans","43","specs","drives","1","type"],"severity":"Error","code":"enum","message":"Request body property plans.43.specs.drives.1.type must be equal to one of the allowed values: HDD, SSD, NVME"},{"location":["response","body","plans","43","type"],"severity":"Error","code":"type","message":"Request body property plans.43.type must be string"},{"location":["response","body","plans","43","type"],"severity":"Error","code":"enum","message":"Request body property plans.43.type must be equal to one of the allowed values: standard, workload_optimized, custom"},{"location":["response","body","plans","44","specs","drives","1","type"],"severity":"Error","code":"enum","message":"Request body property plans.44.specs.drives.1.type must be equal to one of the allowed values: HDD, SSD, NVME"}]}

While the Equinix Metal API does not return this API header natively,
tools such as Spotlight Prism can proxy the API and they may return this
standard error content-type.

Signed-off-by: Marques Johansson <[email protected]>
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.

1 participant