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

http error 403 when accessing https://json-schema.org/draft/2019-09/meta/core #867

Closed
jeromevdl opened this issue Oct 6, 2023 · 3 comments

Comments

@jeromevdl
Copy link

Using the validator Set<ValidationMessage> validationMessages = jsonSchema.validate(jsonNode);, we get the following error in our build on GitHub within a unit test, but not locally. No problem with other schema versions (4, 6 or 7).

com.networknt.schema.JsonSchemaException: java.io.IOException: Server returned HTTP response code: 403 for URL: https://json-schema.org/draft/2019-09/meta/core
at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:457)
at com.networknt.schema.RefValidator.getRefSchema(RefValidator.java:84)
at com.networknt.schema.RefValidator.(RefValidator.java:43)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.networknt.schema.ValidatorTypeCode.newValidator(ValidatorTypeCode.java:162)
at com.networknt.schema.JsonMetaSchema.newValidator(JsonMetaSchema.java:278)
at com.networknt.schema.ValidationContext.newValidator(ValidationContext.java:63)
at com.networknt.schema.JsonSchema.read(JsonSchema.java:295)
at com.networknt.schema.JsonSchema.getValidators(JsonSchema.java:615)
at com.networknt.schema.JsonSchema.validate(JsonSchema.java:388)
at com.networknt.schema.AllOfValidator.validate(AllOfValidator.java:58)
at com.networknt.schema.JsonSchema.validate(JsonSchema.java:393)
at com.networknt.schema.BaseJsonValidator.validate(BaseJsonValidator.java:115)
at software.amazon.lambda.powertools.validation.ValidationUtils.validate(ValidationUtils.java:209)

@jeromevdl
Copy link
Author

Using config.addUriTranslator(URITranslator.prefix("https://json-schema.org", "resource:")); fixes the problem but would be great to understand why there is a 403 if using the remote version...

@stevehu
Copy link
Contributor

stevehu commented Oct 6, 2023

Response code 403 is forbidden error. I tried to access it from the browser and curl from my desktop and it cannot be reproduced. It is a perminent issue or temporary issue? If we always got 403, we might need to debug into it to figure out what is going on. Thanks for reporting it.

@justin-tay
Copy link
Contributor

This is because CloudFlare is blocking requests with specific user agent strings.

curl -H "User-Agent:Java/1." https://json-schema.org/draft/2019-09/meta/core

vs

curl https://json-schema.org/draft/2019-09/meta/core

@stevehu stevehu closed this as completed May 30, 2024
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

No branches or pull requests

3 participants