Skip to content

fix(frontend,plan): restore FILEPATH in SHOW CREATE for file-based external tables; rework query-result dump-format lifecycle (#30570 #31261) - #31466

Merged
mergify[bot] merged 4 commits into
mainfrom
fix/astra-meow-30570-31261-r20261027t051703
Oct 28, 2026
Merged

mergify[bot] merged 4 commits into
mainfrom
fix/astra-meow-30570-31261-r20261027t051703

Conversation

@aptend

@aptend aptend commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

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 the
output file's extension, because doDumpQueryResult (pkg/frontend/query_result.go) never set
ExportParam.ExportFormat and never called the format validation — the suffix-driven logic
(inferFormatFromSuffix / validateExportFormat in pkg/frontend/export.go) was only wired
into the SELECT ... INTO / EXPORT path. The MODUMP path now calls validateExportFormat
before writing, so .jsonl/.jsonline/.ndjson produce JSON Lines and .parquet produces
Parquet through the existing shared ExportConfig write path (init → openNewFile → per-block
write → finish). Unit tests verify the dumped bytes with a real Parquet reader readback
(TestDoDumpQueryResultHonorsFileSuffix) and invalid-UTF8 JSON Lines rejection
(TestDoDumpQueryResultJsonlineRejectsInvalidUTF8). The new BVT case
modump_query_result_error_reuse additionally verifies that MODUMP against an unknown query id
returns 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 replayed
or restored DDL pointed at nothing and the recreated table was unreadable.
buildShowCreateTable now keeps the original FILEPATH in the INFILE clause (S3
credentials 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 positional s3,endpoint,region,bucket,key,secret:file), which would
leak object-store secrets into schema dumps — violating the no-secrets requirement. This head
adds maskServiceArgumentCredentialsForShowCreate (pkg/sql/plan/build_show_util.go), applied
to both the INFILE branch and the explicit-S3 branch's 'filepath' option. It decodes the
service section with the production parseService rules (comma split / csv.ReadAll, service
separator 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) for s3-opts|opts|options|hdfs, and redacts positional
key/secret at argv index 4/5 for s3/minio (mirroring fileservice/get.go
parseFileServiceArguments). Ordinary server-local paths (/data/..., stage://... claims
untouched unless credential-service-claimed) round-trip byte-for-byte, preserving the #31261
replay contract. Because CREATE admission (InitInfileParam) validates only option keys and
never 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:file leaks
argv[4] and is redacted), colonless s3-opts,key=...,secret=... claims, and the
EncodeServiceCSV error fallback (practically unreachable; fail-closed anyway). Valid
non-credential positions (positional prefix/name at index 6/7, s3,ep: credential-free short
form, unknown services, role-arn/external-id) are preserved verbatim.

Validation (raw rcs kept in the review session; evidence recorded):

  • Review-fix unit + production-arc tests (pkg/sql/plan/build_show_util_external_replay_test.go):
    direct masker table cases plus a real CREATE planner → SystemRelAttr_CreateSQL stored
    property → ConstructCreateTableSQL consumer arc proving synthetic secrets never reach
    dump-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.csv and "s3-opts",key=K,secret=S (fully-quoted and
    colonless 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-selected with
    STATIC_CHECK_PACKAGES=./pkg/sql/plan/... (molint + go vet + golangci-lint): rc=0,
    0 issues.. Not claimed: a whole-package ./pkg/sql/plan run, live S3, or a live mo-dump
    of 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.
  • Feature evidence from earlier rounds is unchanged: external_table_show_create_replay
    BVT static oracle + second-root rerun; hardened SHOW CREATE oracle reruns
    (alter_table_add_drop_primary_key 265/265, alter_table_rename_column 270/270,
    show_create_table 64/64, external_table_error_mode 45/45, replay 13/13) under an active
    dispatcher 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_stage row-order fix
    (307/307, that case only). e2e-postrebase.log is reported with its older local base (533e957)
    and is not an artifact of the final HEAD binary.

Source identity and delivery fence:

  • Current head 512d744e8656fe088a2c2938e96d126840956ed9 = feature commit
    2ce641877f on upstream main 1fd12d526e + review-fix Add README.md #1 170195b9fa
    (masker redaction, rebased) + review-fix integrate mysql parser from pingcap #2 512d744e86 (fully-quoted and
    colonless service-argument fail-close); linear rebases only, never merged.
    Complete diff versus base 1fd12d526e is 22 files (+1023/-43), sha256
    a1d54634b269869f1ff340411e916f96a27c5ac81e65a2b303327599a8d828bd;
    delivery-accepted fingerprint, remote readback identical. Superseded head
    be4a044e5d438f70af61ebd69528117f81081dbe (feature on c4946bb74d +
    review-fix Add README.md #1) had complete-diff sha256
    62af31284425a29b942ee97bf70ca939574a6746e7195a31c4001e3c4bde9fcb; older
    superseded head 9033069e3d was the pre-review-fix feature head against
    d4ffbae4 (parent d4ffbae43d55da21526eab01722cbef14bb01ed5), rebased onto
    3b7752551b as cda8df8d0e before any review fix.
  • Known limitations (masked display only): unknown service names are not masked (production
    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.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added kind/bug Something isn't working kind/feature labels Oct 27, 2026
@matrix-meow matrix-meow added the size/L Denotes a PR that changes [500,999] lines label Oct 27, 2026
@aptend
aptend force-pushed the fix/astra-meow-30570-31261-r20261027t051703 branch from 338306a to 9033069 Compare October 27, 2026 13:21
@XuPeng-SH

XuPeng-SH commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 9033069e3dfbb2d856f6f7241348a4924d2a607b

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

aptend added a commit that referenced this pull request Oct 27, 2026
…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.
@aptend
aptend force-pushed the fix/astra-meow-30570-31261-r20261027t051703 branch from 9033069 to be4a044 Compare October 27, 2026 17:03
aptend and others added 2 commits October 28, 2026 04:58
…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.
@aptend
aptend force-pushed the fix/astra-meow-30570-31261-r20261027t051703 branch from be4a044 to 512d744 Compare October 27, 2026 21:10
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ aptend
❌ momo


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.

@XuPeng-SH

XuPeng-SH commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 512d744e8656fe088a2c2938e96d126840956ed9

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@mergify mergify Bot added the queued label Oct 27, 2026
@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as b888c21 at Wed 28 Oct, 00:43 UTC

2 h 22 min in the queue, 56 min of it CI.

So far

  • ✅ Entered the queue Tue 27 Oct, 22:21 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged Wed 28 Oct, 00:43 · b888c21 · squash
Merge conditions: 3 of 3 met

This pull request

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

This branch was previously deployed

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

Labels

kind/bug Something isn't working kind/feature size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

4 participants