Skip to content

fix: Resolve panic when manifest has an int #203

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

Merged
merged 1 commit into from
Jun 12, 2025

Conversation

dhaiducek
Copy link
Contributor

The unstructured package made the decision to not support int types, but that's exactly what our YAML marshaler uses. Changing to type assertions avoids the panic.

ref: https://issues.redhat.com/browse/ACM-18816

@dhaiducek
Copy link
Contributor Author

/cherry-pick release-2.13

@openshift-cherrypick-robot

@dhaiducek: once the present PR merges, I will cherry-pick it on top of release-2.13 in a new PR and assign it to you.

In response to this:

/cherry-pick release-2.13

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@dhaiducek
Copy link
Contributor Author

/cherry-pick release-2.12

@openshift-cherrypick-robot

@dhaiducek: once the present PR merges, I will cherry-pick it on top of release-2.12 in a new PR and assign it to you.

In response to this:

/cherry-pick release-2.12

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@dhaiducek
Copy link
Contributor Author

/hold there might be a simpler option here...

Comment on lines -80 to +81
err := yaml.Unmarshal(yamlBytes, &policy.Object)
err := k8syaml.Unmarshal(yamlBytes, &policy.Object)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the key piece. Kubernetes decided int isn't a safe type, so we need to unmarshal with the Kubernetes YAML parser so it parses to int64 and then we can use the subsequent unstructured calls. The alternative is the route I started out on to manually do the indexing and type assertions.

@dhaiducek dhaiducek force-pushed the 18816-template-panic branch from caf33c7 to 9d21989 Compare June 12, 2025 13:38
Copy link

Copy link
Contributor

@JustinKuli JustinKuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for figuring this one out!

Copy link

openshift-ci bot commented Jun 12, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dhaiducek, JustinKuli

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [JustinKuli,dhaiducek]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the lgtm label Jun 12, 2025
@dhaiducek
Copy link
Contributor Author

/unhold

@openshift-merge-bot openshift-merge-bot bot merged commit 73dd6f9 into stolostron:main Jun 12, 2025
5 checks passed
@openshift-cherrypick-robot

@dhaiducek: #203 failed to apply on top of branch "release-2.13":

Applying: fix: Resolve panic when manifest has an `int`
Using index info to reconstruct a base tree...
M	cmd/template-resolver/client_test.go
M	cmd/template-resolver/utils/resolver_utils.go
M	go.mod
Falling back to patching base and 3-way merge...
Auto-merging go.mod
CONFLICT (content): Merge conflict in go.mod
Auto-merging cmd/template-resolver/utils/resolver_utils.go
Auto-merging cmd/template-resolver/client_test.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 fix: Resolve panic when manifest has an `int`

In response to this:

/cherry-pick release-2.13

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-cherrypick-robot

@dhaiducek: #203 failed to apply on top of branch "release-2.12":

Applying: fix: Resolve panic when manifest has an `int`
Using index info to reconstruct a base tree...
M	cmd/template-resolver/client_test.go
M	cmd/template-resolver/utils/resolver_utils.go
M	go.mod
Falling back to patching base and 3-way merge...
Auto-merging go.mod
CONFLICT (content): Merge conflict in go.mod
Auto-merging cmd/template-resolver/utils/resolver_utils.go
Auto-merging cmd/template-resolver/client_test.go
CONFLICT (content): Merge conflict in cmd/template-resolver/client_test.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 fix: Resolve panic when manifest has an `int`

In response to this:

/cherry-pick release-2.12

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants