(fix): YAML parsing of JSON number to int#21690
(fix): YAML parsing of JSON number to int#21690justinkaseman wants to merge 1 commit intodevelopfrom
Conversation
|
👋 justinkaseman, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
|
✅ No conflicts with other open PRs targeting |
There was a problem hiding this comment.
Pull request overview
Risk Rating: MEDIUM (changes behavior of a shared input decoding helper used across CRE job spec handling)
This PR fixes CRE job input unmarshalling when YAML-originated integers travel through a JSON pipeline with json.Decoder.UseNumber(), causing numeric values to arrive as json.Number and fail decoding into int fields.
Changes:
- Sanitize
JobSpecInputby recursively convertingjson.Numbervalues into Go numeric primitives before YAML marshal/unmarshal. - Add regression tests covering
json.Number→intdecoding (including nested structs/slices) and a native-inthappy path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
deployment/cre/jobs/types/job_spec.go |
Converts json.Number values prior to YAML marshal/unmarshal so numeric YAML inputs decode into typed numeric fields correctly. |
deployment/cre/jobs/types/job_spec_test.go |
Adds regression tests to ensure UnmarshalTo handles json.Number for int fields and still works for native int values. |
Areas requiring scrupulous human review:
convertValueconversion semantics (int vs float vs string fallback) to ensure it matches expectations for all job templates/inputs that can flow through the YAML→JSON→env→JSON pipeline.
Suggested reviewers (per .github/CODEOWNERS for /deployment/cre):
@smartcontractkit/keystone@smartcontractkit/operations-platform
|
|
|
||
| func (j JobSpecInput) UnmarshalTo(target any) error { | ||
| bytes, err := yaml.Marshal(j) | ||
| sanitized := convertJSONNumbers(map[string]any(j)) |
There was a problem hiding this comment.
I'm not sure if this is going to work... at this stage we already lost int types in the nested map[string]any array




Requires
Supports