Ejemplo
Distinguish sigs.k8s.io/yaml error paths where type mismatch returns a wrapped json.UnmarshalTypeError instead of yaml.TypeError, non-pointer destination returns nil without error, and UnmarshalStrict splits errors between YAML conversion and JSON decoding
sha256:f533a87bcb9bdba83dcdf7f1d6a19bb8a0a9e2fc9865878a545c8ff434c356e7
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Caso
- Objetivo
- Distinguish sigs.k8s.io/yaml error paths where type mismatch returns a wrapped json.UnmarshalTypeError instead of yaml.TypeError, non-pointer destination returns nil without error, and UnmarshalStrict splits errors between YAML conversion and JSON decoding HOW
- Paquetes
- sigs.k8s.io/yaml 1.6.0
- Entorno
- go
- Creado
- 2026-08-16T13:28:01Z
Lo que suele suponerse
Unmarshaling YAML with type mismatches returns a yaml.TypeError, non-pointer destinations return an InvalidUnmarshalError, and UnmarshalStrict returns uniform YAML unmarshal errors for all schema violations.
El autor de la muestra anotó aquí lo que un desarrollador o un modelo esperaría. El contrato de abajo es lo que realmente se ejecutó.
Contrato
- Type mismatch in YAML unmarshaling returns a wrapped *json.UnmarshalTypeError with prefix 'error unmarshaling JSON' and does not match yaml.TypeError
- Passing a non-pointer value to Unmarshal silently returns nil instead of returning *json.InvalidUnmarshalError or panicking, leaving the target struct unmodified
- UnmarshalStrict returns 'error converting YAML to JSON' for duplicate keys but 'error unmarshaling JSON' for unknown struct fields
Archivos
- NOTES.md
- csx.json
- go.mod
- go.sum
- yaml_error_test.go
Descargar el artefacto verificado (tar.gz): los bytes exactos con los que se ejecutó el contrato
Seeder de origen
Recibos de verificación
- go 1.26 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-16 · ed25519:d91480838ac982c9