fix: improve error message when adoption-fields annotation is missing - #231
Conversation
|
Hi @shinichitazawa. Thanks for your PR. I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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/test-infra repository. |
bd55eae to
64a8f3b
Compare
|
Thanks @shinichitazawa |
|
It would be nice if this could get merged. AWS recently added a |
|
/retest |
|
@shinichitazawa: Cannot trigger testing until a trusted user reviews the PR and leaves an DetailsIn response to this:
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. |
64a8f3b to
fb96d62
Compare
When using `adoption-policy: adopt` without the `adoption-fields` annotation, `ExtractAdoptionFields` calls `json.Unmarshal` on an empty string, producing a generic "unexpected end of JSON input" error that gives no indication of the actual problem. This change adds an explicit empty-string check that returns a descriptive error explaining that the `adoption-fields` annotation is required, and wraps JSON parse errors with context about which annotation failed. Fixes aws-controllers-k8s/community#2824
fb96d62 to
f691f48
Compare
|
/ok-to-test |
|
/test ec2-controller-test |
|
Thanks for the contribution @shinichitazawa |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: michaelhtm, shinichitazawa The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
When using
services.k8s.aws/adoption-policy: adoptwithout theservices.k8s.aws/adoption-fieldsannotation,ExtractAdoptionFieldsinpkg/runtime/util.gocallsjson.Unmarshalon an empty string, producing the generic Go errorunexpected end of JSON input.This error gives no indication that the
adoption-fieldsannotation is missing, making it very difficult to diagnose — especially since it becomes aTerminalErrorthat permanently blocks reconciliation.Changes
ExtractAdoptionFieldsthat returns a descriptive error message explaining that theadoption-fieldsannotation is required whenadoption-policyis set toadoptjson.Unmarshalerror withfmt.Errorfand%wto provide context about which annotation failed to parseBefore
After
Testing
go test ./pkg/runtime/...)Fixes aws-controllers-k8s/community#2824
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.