fix: ensure proper shell quoting for parameters#837
Merged
Conversation
|
@freeznet:Thanks for your contribution. For this PR, do we need to update docs? |
There was a problem hiding this comment.
Pull request overview
This PR fixes shell-parsing corruption when Function Mesh builds runtime/admin commands via bash -c by introducing a single, consistent shell-literal quoting helper and applying it to JSON/parameter arguments that may contain embedded single quotes.
Changes:
- Added
shellQuoteLiteral()to correctly single-quote literal arguments (escaping embedded'as'"'"'). - Applied shell-safe quoting to
--function_details,--client_auth_params, and admin/download--auth-paramspaths (OAuth2 + generic auth). - Updated and extended unit tests to validate correct escaping behavior for real-world configs (e.g.,
timePartitionPatterncontaining single quotes).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| controllers/spec/common.go | Introduces shellQuoteLiteral() and uses it for function details + auth params in shell-command construction. |
| api/compute/v1alpha1/common.go | Adjusts OAuth2 AuthenticationParameters() to return raw JSON (quoting now handled at command construction). |
| controllers/spec/common_test.go | Updates expected commands to use shellQuoteLiteral(); adds focused tests for quoting behavior. |
| controllers/spec/function_test.go | Updates function-details assertions and adds sink-specific tests covering embedded quote escaping. |
| .gitignore | Ignores repository /tmp directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jiangpengcheng
previously approved these changes
Mar 27, 2026
jiangpengcheng
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(If this PR fixes a github issue, please add
Fixes #<xyz>.)Fixes #
(or if this PR is one task of a github issue, please add
Master Issue: #<xyz>to link to the master issue.)Master Issue: #
Motivation
Function Mesh currently builds the Java runtime startup command through
bash -cand passesFunctionDetailsas a single--function_detailsargument. The JSON payload is wrapped in single quotes, but embedded single quotes inside the payload are not escaped.This becomes a real problem for connector configs that legitimately rely on single quotes. One concrete example is the cloud storage sink setting below:
timePartitionPattern: yyyy-MM-dd/HH'h'-mm'm'During shell parsing, those embedded quotes are consumed instead of being preserved as literal characters. As a result, the runtime eventually sees:
yyyy-MM-dd/HHh-mmminstead of the original value, and the sink fails to start with:
IllegalArgumentException: Too many pattern letters: mThis is not limited to
timePartitionPattern. The same quoting pattern is also used when passing auth-related JSON flags such as--client_auth_paramsand--auth-params, which means any payload containing single quotes can be corrupted before it reaches the Pulsar runtime.This PR fixes the issue by centralizing shell-safe quoting for literal command arguments and applying it consistently to
--function_details,--client_auth_params, and admin/download auth parameter flags.Modifications
Describe the modifications you've done.
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Documentation
Check the box below.
Need to update docs?
doc-required(If you need help on updating docs, create a doc issue)
no-need-doc(Please explain why)
doc(If this PR contains doc changes)