Skip to content

Return an error instead of panicking on a valueless mount option - #2271

Open
arpitjain099 wants to merge 1 commit into
knative:mainfrom
arpitjain099:fix/mount-readonly-missing-value
Open

arpitjain099 wants to merge 1 commit into
knative:mainfrom
arpitjain099:fix/mount-readonly-missing-value

Conversation

@arpitjain099

Copy link
Copy Markdown

Description

kn service create foo --image ... --mount /mydir=ed:ed1:readOnly panics with index out of range [1] with length 1. parseMountOptions splits each option on = and reads pair[1] for the readonly case without checking that the split produced two elements, so leaving off the value crashes the CLI instead of printing a usage error. The flag help documents readOnly=true | false, so a bare readOnly is a plausible typo.

While in there I removed a leftover in getMountInfo: it splits the option string and runs a switch whose only case is empty, then ignores the result. It has no effect.

Changes

  • Reject a readonly mount option with no value and return an error naming the option
  • Drop the no-op switch in getMountInfo
  • Test covering readonly=true, readonly=false, readonly=, bare readonly and an unknown option

Reference

Fixes #

Release Note

Using --mount with a readOnly option and no value now returns an error instead of panicking.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@knative-prow

knative-prow Bot commented Sep 25, 2026

Copy link
Copy Markdown

Welcome @arpitjain099! It looks like this is your first PR to knative/client 🎉

@knative-prow

knative-prow Bot commented Sep 25, 2026

Copy link
Copy Markdown

Hi @arpitjain099. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@knative-prow knative-prow Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 25, 2026
@knative-prow

knative-prow Bot commented Sep 25, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: arpitjain099
Once this PR has been reviewed and has the lgtm label, please assign dsimansk for approval. For more information see the Code Review Process.

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

Details Needs approval from an approver in each of these files:

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

@knative-prow
knative-prow Bot requested review from dprotaso and dsimansk September 25, 2026 04:23
@knative-prow knative-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant