this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

encoding/jsonschema: adjust for net/url fix in go@master

Running Go at master, I suddenly noticed a few new failures here:

external_test.go:260: unexpectedly more correct behavior (test success) on skipped test
external_test.go:154: txtar:
exec cue def json+jsonschema: schema.json
! exec cue vet -c instance.json json+jsonschema: schema.json

-- schema.json --
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"format": "iri"
}
-- instance.json --
"http://2001:0db8:85a3:0000:0000:8a2e:0370:7334"

It turns out that this is due to the fix upstream for
https://github.com/golang/go/issues/31024.
We actually want the new and fixed behavior, but just like we did with
the fix supporting Unicode character classes in regular expressions,
continue tracking the behavior of stable Go (1.25) in testdata.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ib2c2121c01990ed9329082cbb059d976b38009b2
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1224252
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>

+24 -1
+24 -1
encoding/jsonschema/external_test.go
··· 15 15 package jsonschema_test 16 16 17 17 import ( 18 + "bytes" 18 19 stdjson "encoding/json" 19 20 "fmt" 20 21 "io" 21 22 "maps" 23 + "net/url" 22 24 "os" 23 25 "path" 24 26 "regexp" ··· 90 92 return err == nil 91 93 }() 92 94 95 + var fixesParsingIPv6HostWithoutBrackets = func() bool { 96 + // We use Sprintf so that staticcheck on Go 1.26 and later does not 97 + // helpfully report that this URL will always fail to parse. 98 + _, err := url.Parse(fmt.Sprintf("%s://2001:0db8:85a3:0000:0000:8a2e:0370:7334", "http")) 99 + return err != nil 100 + }() 101 + 93 102 func runExternalSchemaTests(t *testing.T, m *cuetdtest.M, filename string, s *externaltest.Schema) { 94 103 t.Logf("file %v", path.Join("testdata/external", filename)) 95 104 ctx := m.CueContext() ··· 106 115 t.Skipf("skipping test for unknown schema version %v", versStr) 107 116 } 108 117 109 - // Go 1.25.0 implements Unicode category aliases in regular expressions, 118 + // Go 1.25 implements Unicode category aliases in regular expressions, 110 119 // and so e.g. \p{Letter} did not work on Go 1.24.x releases. 120 + // See: https://github.com/golang/go/issues/70780 111 121 // Our tests must run on the latest two stable Go versions, currently 1.24 and 1.25, 112 122 // where such character classes lead to schema compilation errors on 1.24. 113 123 // ··· 115 125 // TODO: get rid of this whole thing once we require Go 1.25 or later in the future. 116 126 if rxCharacterClassCategoryAlias.Match(s.Schema) && !supportsCharacterClassCategoryAlias { 117 127 t.Skip("regexp character classes for Unicode category aliases work only on Go 1.25 and later") 128 + } 129 + 130 + // Go 1.26 fixes [url.Parse] so that it correctly rejects IPv6 hosts 131 + // without the required surrounding square brackets. 132 + // See: https://github.com/golang/go/issues/31024 133 + // Our tests must run on the latest two stable Go versions, currently 1.24 and 1.25, 134 + // where such behavior is still buggy. 135 + // 136 + // As a temporary compromise, skip the test on 1.26 or later; 137 + // we care about testing the behavior that most CUE users will see today. 138 + // TODO: get rid of this whole thing once we require Go 1.26 or later in the future. 139 + if bytes.Contains(s.Schema, []byte(`"iri"`)) && fixesParsingIPv6HostWithoutBrackets { 140 + t.Skip("net/url.Parse tightens behavior on IPv6 hosts on Go 1.26 and later") 118 141 } 119 142 120 143 schemaAST, extractErr := jsonschema.Extract(jsonValue, &jsonschema.Config{