mcp: fix appendBoolFlag to handle explicit false values#3746
Conversation
Previously appendBoolFlag only appended the flag when value was true, silently dropping explicit false values. This meant agents could not explicitly disable bool flags like --insecure or --verbose. Fix uses proper tri-state semantics: nil -> omit flag entirely (not provided) true -> --flag false -> --flag=false Also updates argsToMap in tools_test.go to correctly parse --flag=value format, and adds TestAppendBoolFlag covering all three cases. Fixes knative#3705 Signed-off-by: Thonmay <mdthoriqulislam384@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: thonmay The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @thonmay. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. 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-sigs/prow repository. |
|
Closing this in favor of #3709 which was opened earlier by @Elvand-Lie and addresses the same issue. Sorry for the duplicate. |
Changes
Fixes a correctness bug in
appendBoolFlag: explicitfalsevalues were silently dropped, making it impossible for agents to explicitly disable bool flags like--insecureor--verbose.Before: only appended the flag when value was
true. Explicitfalsewas ignored.After (tri-state semantics):
nil— omit flag entirely (not provided by agent)true—--flagfalse—--flag=falseAlso fixes
argsToMapin tools_test.go to correctly parse--flag=valueformat. Previously--verbose=falsewas treated as a boolean flag with empty value instead of a string flag with valuefalse.Tests added:
TestAppendBoolFlagwith subtests for nil/true/false casesAll existing tests pass.
/kind bug
Fixes #3705