Skip to content

[KYUUBI #7727][UTIL] Trim each side of the pair in genKeyValuePair - #7728

Open
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:kyuubi-util-scala-genkeyvaluepair-trim
Open

[KYUUBI #7727][UTIL] Trim each side of the pair in genKeyValuePair#7728
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:kyuubi-util-scala-genkeyvaluepair-trim

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Why are the changes needed?

Closes #7727.

genKeyValuePair trimmed only the concatenated string (s"$key=$value".trim), so whitespace between the key and value survived: genKeyValuePair("abc ", "123") returned "abc =123". redactConfValues splits an assembled argument on the first = and matches the key against an exact key set, so a spaced key ("<key> =") misses the set and the value is not redacted.

This matters for the Data Agent engine's API key. kyuubi.engine.data.agent.openai.api.key is not matched by the default pattern-based redaction, so exact-key redaction is its only guard, and session conf keys are not trimmed on the way to the engine command. A key carrying a trailing space slipped both stages and logged the API key value. Trimming each side (s"${key.trim}=${value.trim}") makes the assembled pair carry no inner whitespace, so the exact-key stage sees the clean key. Utils.redactCommandLineArgs also assembles through genKeyValuePair, so the same fix closes the hole at both assembly points.

How was this patch tested?

Added CommandUtilsSuite cases: symmetric-trim assertions (genKeyValuePair("abc ", " 123") -> "abc=123", including a tab) and a redaction round-trip that assembles a spaced Data Agent api-key argument and asserts redactConfValues masks it. Both fail on the old .trim.

build/mvn test -pl kyuubi-util-scala -am
build/mvn scalastyle:check spotless:check -pl kyuubi-util-scala -am
build/mvn test -pl kyuubi-common -am -DwildcardSuites=org.apache.kyuubi.UtilsSuite

kyuubi-util-scala green on Zulu 17.0.18 (22/22), scalastyle 0 errors, spotless clean; kyuubi-common UtilsSuite (which exercises redactCommandLineArgs) 14/14.

Was this patch assisted by generative AI tooling?

Assisted-by: Claude Opus 4.8

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spaced conf keys escape exact-key redaction in logged engine commands

2 participants