Comments (3)
I'll raise a PR soon to fix that
from go-jsonschema.
hi @lucasvmiguel, the PR has been merged and your change has been released as part of the release v0.14.1, so I'm closing this issue.
Thank you for contributing to go-jsonschema! 🚀
from go-jsonschema.
Weird, I'm running whatever go install github.com/atombender/go-jsonschema@latest
gave me 3 days ago, and I think I'm still being bitten by this bug...
$ go list -m all | grep json
github.com/atombender/go-jsonschema v0.14.1
What was generated from go-jsonschema -p cves --resolve-extension json /tmp/cve_api_json_2.0.schema
from here:
// UnmarshalJSON implements json.Unmarshaler.
func (j *LangString) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if v, ok := raw["lang"]; !ok || v == nil {
return fmt.Errorf("field lang in LangString: required")
}
if v, ok := raw["value"]; !ok || v == nil {
return fmt.Errorf("field value in LangString: required")
}
type Plain LangString
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
if len(plain.Value) > 4096 {
return fmt.Errorf("field %s length: must be <= %d", "value", 4096)
}
*j = LangString(plain)
return nil
}
Failed to decode "../test_data/nvdcve-2.0-2020.json": field value length: must be <= 4096
The record in question is https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2020-35800 (the Spanish description field), which by my calculations, has a length of exactly 4,096.
I added a bit of additional instrumentation, and ended up with:
Failed to decode "../test_data/nvdcve-2.0-2020.json": field value length: must be <= 4096, have 4098
So something is afoot here with the decoding I think, not this logic, although, I added even more instrumentation (VS Code was unhelpfully truncating my view of these mysterious extra characters and:
Failed to decode "../test_data/nvdcve-2.0-2020.json": field value length: must be <= 4096, have 4098 with content "Determinados dispositivos NETGEAR están afectados por una configuración incorrecta de los ajustes de seguridad. Esto afecta a AC2100 versiones < 1.2.0.72, AC2400 versiones < 1.2.0.72, AC2600 versiones < 1.2.0.72, CBK40 versiones < 2.5.0.10, CBR40 versiones < 2.5.0.10, D6000 versiones < 1.0.0.80, D6220 versiones < 1.0.0.60, D6400 versiones < 1.0.0.94, D7000v2 versiones < 1.0.0.62, D7800 versiones < 1.0.3.48, D8500 versiones < 1.0.3.50, DC112A versiones < 1.0.0.48, DGN2200v4 versiones < 1.0.0.114, DM200 versiones < 1.0.0.66, EAX20 versiones < 1.0.0.36, EAX80 versiones < 1.0.1.62, EX2700 versiones < 1.0.1.58, EX3110 versiones < 1.0.1.68, EX3700 versiones < 1.0.0.84, EX3800 versiones < 1.0.0.84, EX3920 versiones < 1.0.0.84, EX6000 versiones < 1.0.0.44, EX6100v2 versiones < 1.0.1.94, EX6110 versiones < 1.0.1.68, EX6120 versiones < 1.0. 0.54, EX6130 versiones < 1.0.0.36, EX6150v1 versiones < 1.0.0.46, EX6150v2 versiones < 1.0.1.94, EX6200v1 versiones < 1.0.3.94, EX6250 versiones < 1.0.0.128, EX6400 versiones < 1.0.2.152, EX6400v2 versiones < 1.0.0.128, EX6410 versiones < 1.0.0.128, EX6920 versiones < 1.0.0.54, EX7000 versiones < 1.0.1.90, EX7300 versiones < 1.0.2.152, EX7300v2 versiones < 1.0.0.128, EX7320 versiones < 1.0.0.128, EX7500 versiones < 1.0.0.68, EX7700 versiones < 1.0.0.210, EX8000 antes e 1.0.1.224, MK62 versiones < 1.0.5.102, MR60 versiones < 1.0.5.102, MS60 versiones < 1.0.5.102, R6120 versiones < 1.0.0.70, R6220 versiones < 1.1.0.100, R6230 versiones < 1.1.0.100, R6250 versiones < 1.0.4.42, R6260 versiones < 1.1 .0.76, R6300v2 versiones < 1.0.4.42, R6330 versiones < 1.1.0.76, R6350 versiones < 1.1.0.76, R6400v1 versiones < 1.0.1.62, R6400v2 versiones < 1.0.4.98, R6700v1 versiones < 1.0.2.16, R6700v2 versiones < 1.2.0.72, R6700v3 versiones < 1.0.4.98, R6800 versiones < 1.2.0.72, R6800 antes 1.2.0.72, R6850 versiones < 1.1.0.76, R6900 versiones < 1.0.2.16, R6900P versiones < 1.3.2.124, R6900v2 versiones < 1.2.0.72, R7000 versiones < 1.0.11.106, R7000P versiones < 1.3.2.124, R7100LG versiones < 1.0.0.56, R7200 versiones < 1.2. 0.72, R7350 versiones < 1.2.0.72, R7400 versiones < 1.2.0.72, R7450 versiones < 1.2.0.72, R7500v2 versiones < 1.0.3.48, R7800 versiones < 1.0.2.74, R7850 versiones < 1.0.5.60, R7900 versiones < 1.0.4.26, R7900P versiones < 1.4.1.62, R7960P versiones < 1.4.1.62, R8000 versiones < 1.0.4.58, R8000P versiones < 1.4.1.62, R8300 versiones < 1.0.2.134, R8500 versiones < 1.0.2.134, R8900 versiones < 1.0.5.24, R9000 versiones < 1.0.5.24, RAX120 versiones < 1.0.1.136, RAX15 versiones < 1.0.1.64, RAX20 versiones < 1.0.1.64, RAX200 versiones < 1.0.5.24, RAX35 versiones < 1.0.3.80, RAX40 versiones < 1.0.3.80, RAX45 versiones < 1.0.2.64, RAX50 versiones < 1.0.2.64, RAX75 versiones < 1.0.3.102, RAX80 versiones < 1.0. 3.102, RB K12 versiones < 2.6.1.44, RBR10 versiones < 2.6.1.44, RBS10 versiones < 2.6.1.44, RBK20 versiones < 2.6.1.38, RBR20 versiones < 2.6.1.36, RBS20 versiones < 2.6.1.38, RBK40 versiones < 2.6.1.38, RBR40 versiones < 2.6.1.38, RBS40 antes 2.6.1.38, RBK50 versiones < 2.6.1.40, RBR50 versiones < 2.6.1.40, RBS50 versiones < 2.6.1.40, RBK752 versiones < 3.2.16.6, RBR750 versiones < 3.2.16.6, RBS750 versiones < 3.2.16.6, RBK842 versiones < 3.2.16.6, RBR840 versiones < 3.2. 16.6, RBS840 versiones < 3.2.16.6, RBK852 versiones < 3.2.16.6, RBR850 versiones < 3.2.16.6, RBS850 versiones < 3.2.16.6, RBS40V versiones < 2.5.1.6, RBS40V-200 versiones < 1.0.0.46, RBS50Y versiones < 2.6.1.40, RBW30 versiones < 2.5. 0.4, RS400 versiones < 1.5.0.48, WN2500RPv2 versiones < 1.0.1.56, WN3000RPv3 versiones < 1.0.2.86, WN3500RPv1 versiones < 1.0.0.28, WNDR3400v3 versiones < 1.0.1.32, WNR1000v3 versiones < 1.0.2.78, WNR2000v2 versiones < 1.2.0.12, XR30"
Again, by my calculations, the content of plain.Value
seems to have a length of exactly 4,096.
I am officially very confused. If the length was way out, I'd say something unexpected was going on with respect to Unicode, oh wait, there's this  
in there, which is a Unicode non-breaking space?
from go-jsonschema.
Related Issues (20)
- Handling duplicate types HOT 15
- Enum integers are generated as floats. HOT 5
- local file ref failure HOT 4
- Fails to generate schema for github-workflow HOT 3
- Go install complains on go.mod HOT 4
- Generated Unmarshal for fields with `time.Time` HOT 5
- How to specify a root directory for `$ref` resolution? HOT 1
- CVE Schema: could not generate type for field "...": definition does not exist in schema: HOT 6
- feat: Use of project as package
- Nested struct support? HOT 1
- Fails to generate for Signal K, cannot generate referenced type. HOT 1
- Nullable nested object support
- Incorrect string length validation for some strings. HOT 1
- Does not generate anything for the GeoJson schema
- improve support for additionalProperties HOT 1
- Problems generating structs from schema.
- minItems wrong implementation HOT 4
- Object Properties do not generate valid Unmarshal code
- Handling of `required` properties in objects HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-jsonschema.