Repository navigation
fix(frontend,plan): restore FILEPATH in SHOW CREATE for file-based external tables; rework query-result dump-format lifecycle (#30570 #31261) - #31466
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
338306a to
9033069
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 9033069e3dfbb2d856f6f7241348a4924d2a607b
Assessment: request_changes
The complete delta introduces one confirmed credential-disclosure regression. Explicit S3-option masking works, but does not protect credentials embedded in INFILE paths.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
- P1
pkg/sql/plan/build_show_util.go:1563: Create an ordinary external table with INFILE{'filepath'='s3-opts,endpoint=https://owned.invalid,region=us-east-1,bucket=b,key=K,secret=S:rows.csv','format'='csv'}, then execute SHOW CREATE TABLE.
Impact: The newly preserved FILEPATH exposes the embedded object-store credentials in SHOW CREATE output and downstream dumps. This violates issue #31261's explicit no-secrets requirement. Redact credential-bearing service arguments while retaining ordinary local paths, and add regression coverage.
Evidence: The production CREATE planner and SHOW CREATE renderer reproduce the disclosure: credential-probe-head.log contains both synthetic credentials. This path remains ScanType INFILE, bypassing the S3 masker; fileservice/get.go:65-108 supports this service-argument syntax. Local-path and explicit-S3 controls pass. The same credential assertion passes with the exact base renderer substituted. Logs, overlays and matching receipts are retained under /home/xupeng/.local/state/mo-bot/jobs/dfa5e7b472ca25062c7d0ce7/attempt-1 and indexed in validation-audit.json.
Validation:
-
Passed 19 focused tests under the race detector across frontend and plan, covering MODUMP formats, cancellation, cleanup, session reuse and SHOW CREATE serialization.
-
Credential probe failed on the candidate; both unaffected controls passed. The base-renderer control passed.
-
Preflight, native prerequisite build and final evidence audit passed. Verified source fingerprints, native provenance, command receipts, retained logs and unchanged source.
-
Reviewed all 22 changed files, both linked issues and complete discussion; saved discussion-assessment.json.
Limitations:
-
The credential probe exercised production planning/rendering with a mock catalog, not a live SQL or S3 server.
-
No live Proxy/two-CN or mo-dump restore matrix was rerun. Author reports lacked independently retained artifacts; one E2E report used an older base.
-
Frozen CI reports 21 successful, 14 skipped and 2 neutral checks; raw CI logs were unavailable.
…tions (#31466) Review 5669247494 (XuPeng-SH/mo-bot, CHANGES_REQUESTED): SHOW CREATE renders INFILE 'FILEPATH'='s3-opts,endpoint=...,key=K,secret=S:rows.csv' verbatim, disclosing object-store credentials into schema dumps (#31261). * maskServiceArgumentCredentialsForShowCreate: decode the service section with the production parseService rules (fast comma split / csv.ReadAll, separator at the LAST colon) and redact k=v credential keys for s3-opts/opts/options/hdfs plus positional key/secret at argv[4]/[5] for s3/minio. Ordinary server-local paths and unknown services round-trip byte-for-byte (#30570 replay contract preserved). * Fail closed for malformed service-claimed forms CREATE admission nevertheless persists (InitInfileParam validates option keys only): CSV grammar errors, short-but-credential-bearing positional forms and colonless s3-opts claims render <redacted> instead of raw credentials; the EncodeServiceCSV fallback is fail-closed as well. * Apply the same masking to the explicit-S3 branch's 'filepath' option. * Regression: direct masker table tests plus production CREATE planner -> SystemRelAttr_CreateSQL storage -> ConstructCreateTableSQL consumer arcs proving synthetic secrets never reach dump-visible output while local paths stay exact.
9033069 to
be4a044
Compare
…tions (#31466) Review 5669247494 (XuPeng-SH/mo-bot, CHANGES_REQUESTED): SHOW CREATE renders INFILE 'FILEPATH'='s3-opts,endpoint=...,key=K,secret=S:rows.csv' verbatim, disclosing object-store credentials into schema dumps (#31261). * maskServiceArgumentCredentialsForShowCreate: decode the service section with the production parseService rules (fast comma split / csv.ReadAll, separator at the LAST colon) and redact k=v credential keys for s3-opts/opts/options/hdfs plus positional key/secret at argv[4]/[5] for s3/minio. Ordinary server-local paths and unknown services round-trip byte-for-byte (#30570 replay contract preserved). * Fail closed for malformed service-claimed forms CREATE admission nevertheless persists (InitInfileParam validates option keys only): CSV grammar errors, short-but-credential-bearing positional forms and colonless s3-opts claims render <redacted> instead of raw credentials; the EncodeServiceCSV fallback is fail-closed as well. * Apply the same masking to the explicit-S3 branch's 'filepath' option. * Regression: direct masker table tests plus production CREATE planner -> SystemRelAttr_CreateSQL storage -> ConstructCreateTableSQL consumer arcs proving synthetic secrets never reach dump-visible output while local paths stay exact.
…-argument FILEPATH masking in SHOW CREATE (#31466)
be4a044 to
512d744
Compare
|
momo seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 512d744e8656fe088a2c2938e96d126840956ed9
Assessment: approve
Reviewed the complete 22-file delta, linked issues and discussion. Both prior credential-disclosure findings are resolved. FILEPATH preservation, credential masking and MODUMP format/lifecycle integration have no remaining actionable findings.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
Validation:
-
Current-head focused planner tests passed: seven top-level tests and 22 subtests, including both previously failing credential cases.
-
Qualified nine retained frontend race-test results covering formats, Parquet readback, cancellation, cleanup and session reuse.
-
Verified native inputs/artifacts, command receipts, retained logs and unchanged source. Final audit passed; evidence is indexed in validation-audit.json.
-
Saved discussion-assessment.json covering all seven discussion keys. Frozen CI reports 21 successful checks.
Limitations:
-
Renderer tests use production parsing/planning with a mock catalog; live S3, Proxy/two-CN and mo-dump restore checks were not rerun.
-
Raw author integration and CI logs were unavailable. The CLA notice remains a separate repository publication concern.
|
Queued — the merge queue status continues in this comment ↓. |
✅ Merged into
|
| Condition | Required by | |
|---|---|---|
| ✅ | #review-threads-unresolved = 0 |
GitHub branch protection |
| ✅ | github-review-approved |
GitHub branch protection |
The batch, tested in place
| Condition | Required by | |
|---|---|---|
| ✅ | any of: check-success = CI Required, check-neutral = CI Required, check-skipped = CI Required |
GitHub branch protection |
Times in UTC · dashboard · how the merge queue works
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #30570
Fixes #31261
What this PR does / why we need it:
#30570:
MODUMP QUERY_RESULT '<query-id>' INTO '<path>'always wrote CSV regardless of theoutput file's extension, because
doDumpQueryResult(pkg/frontend/query_result.go) never setExportParam.ExportFormatand never called the format validation — the suffix-driven logic(
inferFormatFromSuffix/validateExportFormatinpkg/frontend/export.go) was only wiredinto the
SELECT ... INTO/EXPORTpath. The MODUMP path now callsvalidateExportFormatbefore writing, so
.jsonl/.jsonline/.ndjsonproduce JSON Lines and.parquetproducesParquet through the existing shared
ExportConfigwrite path (init → openNewFile → per-blockwrite → finish). Unit tests verify the dumped bytes with a real Parquet reader readback
(
TestDoDumpQueryResultHonorsFileSuffix) and invalid-UTF8 JSON Lines rejection(
TestDoDumpQueryResultJsonlineRejectsInvalidUTF8). The new BVT casemodump_query_result_error_reuseadditionally verifies that MODUMP against an unknown query idreturns a deterministic error and the same connection stays usable for the next statement —
that is failure-path regression verification, not the issue's original symptom.
#31261: SHOW CREATE TABLE for ordinary (non-Hive, file-based) external tables emitted
INFILE{'FILEPATH'=''}— the FILEPATH was dropped from the generated DDL, so a replayedor restored DDL pointed at nothing and the recreated table was unreadable.
buildShowCreateTablenow keeps the original FILEPATH in the INFILE clause (S3credentials stay masked); the emitted DDL is re-executable as-is for ordinary server-local paths, while credential-bearing service-argument paths are intentionally redacted (
<redacted>) and the owner must re-supply credentials before the replayed table is usable.Review follow-up on #31261 (this head): the retained FILEPATH can itself embed
fileservice service-argument credentials (
'FILEPATH'='s3-opts,endpoint=...,key=K, secret=S:rows.csv'or positionals3,endpoint,region,bucket,key,secret:file), which wouldleak object-store secrets into schema dumps — violating the no-secrets requirement. This head
adds
maskServiceArgumentCredentialsForShowCreate(pkg/sql/plan/build_show_util.go), appliedto both the INFILE branch and the explicit-S3 branch's
'filepath'option. It decodes theservice section with the production
parseServicerules (comma split /csv.ReadAll, serviceseparator at the LAST colon), redacts k=v credential keys (
key,key-id,secret,key-secret,secret-id,bearer-token,security-token,token,session-token,kerberos-password; case-insensitive) fors3-opts|opts|options|hdfs, and redacts positionalkey/secret at argv index 4/5 for
s3/minio(mirroringfileservice/get.goparseFileServiceArguments). Ordinary server-local paths (/data/...,stage://...claimsuntouched unless credential-service-claimed) round-trip byte-for-byte, preserving the #31261
replay contract. Because CREATE admission (
InitInfileParam) validates only option keys andnever parses the path grammar, malformed-but-credential-bearing forms are reachable in stored
metadata, so the renderer fails closed for: CSV-grammar errors on a credential-claimed section,
short-but-credential-bearing positional forms (5-field
s3,ep,region,bucket,KEY:fileleaksargv[4] and is redacted), colonless
s3-opts,key=...,secret=...claims, and theEncodeServiceCSVerror fallback (practically unreachable; fail-closed anyway). Validnon-credential positions (positional prefix/name at index 6/7,
s3,ep:credential-free shortform, unknown services,
role-arn/external-id) are preserved verbatim.Validation (raw rcs kept in the review session; evidence recorded):
pkg/sql/plan/build_show_util_external_replay_test.go):direct masker table cases plus a real CREATE planner →
SystemRelAttr_CreateSQLstoredproperty →
ConstructCreateTableSQLconsumer arc proving synthetic secrets never reachdump-visible SHOW CREATE output while local paths stay byte-exact; malformed quoted
service sections, short positional forms, colonless claims, and the explicit-S3 branch
credential-qualified filepath are covered, together with the review witnesses
"s3-opts",key=K,"secret=S:rows.csvand"s3-opts",key=K,secret=S(fully-quoted andcolonless claims, fail-closed) and quoted-local-path negative controls preserved verbatim.
Focused CGO at current head
512d744e8656fe088a2c2938e96d126840956ed9(command:GOWORK=off CGO_ENABLED=1 .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=600s -run 'TestFormatInfileExternalOptionsMasksServiceArgumentCredentials|TestShowCreateCreatePlannerExternalTableMasksServiceArgumentCredentials|TestShowCreateExternalMasksFailClosedAndS3BranchFilepath|TestGetMaskTypeExternal|TestConstructCreateTableSQLOpositionExternalOptions|TestInfileExport' -v ./pkg/sql/plan/...):rc=0 — 3 top-level tests matched, 25 PASS (3 top-level + 22 subtests) / 0 FAIL; the other
3 named patterns matched no tests and 18 other listed packages printed
[no tests to run].Scoped static at current head: repo target
static-check-selectedwithSTATIC_CHECK_PACKAGES=./pkg/sql/plan/...(molint + go vet + golangci-lint): rc=0,0 issues.. Not claimed: a whole-package./pkg/sql/planrun, live S3, or a live mo-dumpof the redacted output (assertions are on the exact rendered string that mo-dump captures);
prior "6 top-level tests, 7 PASS" evidence belongs to the superseded head and does not
carry to this head.
external_table_show_create_replayBVT static oracle + second-root rerun; hardened SHOW CREATE oracle reruns
(
alter_table_add_drop_primary_key265/265,alter_table_rename_column270/270,show_create_table64/64,external_table_error_mode45/45, replay 13/13) under an activedispatcher port guard (23000-23999, HAKeeper 127.0.0.1:23401, owned-PID cleanup);
negative-control mutation (rc=1) proving the oracle is live; the [Bug]: SHOW CREATE TABLE drops FILEPATH for ordinary CSV external tables, leaving restored tables unreadable #31261 isolated-cluster
mo-dump → native mysql restore → identical rowset chain;
stage_based_stagerow-order fix(307/307, that case only).
e2e-postrebase.logis reported with its older local base (533e957)and is not an artifact of the final HEAD binary.
Source identity and delivery fence:
512d744e8656fe088a2c2938e96d126840956ed9= feature commit2ce641877fon upstream main1fd12d526e+ review-fix Add README.md #1170195b9fa(masker redaction, rebased) + review-fix integrate mysql parser from pingcap #2
512d744e86(fully-quoted andcolonless service-argument fail-close); linear rebases only, never merged.
Complete diff versus base
1fd12d526eis 22 files (+1023/-43), sha256a1d54634b269869f1ff340411e916f96a27c5ac81e65a2b303327599a8d828bd;delivery-accepted fingerprint, remote readback identical. Superseded head
be4a044e5d438f70af61ebd69528117f81081dbe(feature onc4946bb74d+review-fix Add README.md #1) had complete-diff sha256
62af31284425a29b942ee97bf70ca939574a6746e7195a31c4001e3c4bde9fcb; oldersuperseded head
9033069e3dwas the pre-review-fix feature head againstd4ffbae4(parentd4ffbae43d55da21526eab01722cbef14bb01ed5), rebased onto3b7752551bascda8df8d0ebefore any review fix.admits no other credential-bearing service than the listed set); arbitrary data in
non-credential fields is not masked; the stored catalog metadata retains the original
credentials (as designed for restore access) — only rendered SHOW CREATE / dump text is
redacted.
Port-guard boundary: one consolidation service run during local verification fell inside a
brief port-guard rebind window and lacked a complete owned-socket audit; no claim is made
about that window. Only the subsequent fully-audited, guard-on reruns are asserted as
service evidence above.
Known-risk notes: the change is additive in SHOW CREATE text (FILEPATH now present for
file external tables, credential-bearing service arguments redacted) and adds one validation
call on the MODUMP path; no on-disk format, catalog metadata, or wire-protocol change.