Skip to content

[Bug]: Python SDK Stage.load_files fallback calls nonexistent from_stage for valid text files #31741

Closed

Description

@Ariznawlll

Description

Python SDK Stage.load_files() cannot load a valid stage file whose suffix is not one of its hard-coded recognized extensions. Its generic fallback invokes LoadDataManager.from_stage, a method that does not exist. The method returns an error string for that file and leaves its destination empty. The same stage file is readable through the supported load_data.from_file() API.

Environment

  • Official main: c6683bd2f531dcaa80e153c0924dac619c49dc9d, built from the same source; runtime git_version() = c6683bd2f5.
  • Isolated local 1 LOG / 1 TN / 2 CN; Python SDK from the same commit.
  • Three fresh databases; synchronous client on CN1 and asynchronous client on CN2.

Steps to reproduce

Create a local stage s containing two identical comma-separated text files, data.csv and data.txt:

1,alpha
2,beta

Create separate csv_t, txt_t, and control_t tables with id INT PRIMARY KEY, v VARCHAR(20). With a connected SDK client:

stage = client.stage.get('s')
results = stage.load_files({'data.csv': 'csv_t', 'data.txt': 'txt_t'})
print(results['data.txt'])
# Error: 'LoadDataManager' object has no attribute 'from_stage'

client.load_data.from_file('stage://s/data.txt', 'control_t')

For the asynchronous client, await the returned awaitables from supported file entries before inspecting their tables. The .txt fallback itself returns the same error string immediately.

Actual behavior

results['data.txt'] is the captured AttributeError above; txt_t is empty. No server LOAD for that mapping is sent. The .csv mapping in the same batch loads both expected rows. Direct from_file with the same stage:// URL loads both rows into control_t.

Expected behavior

The documented generic fallback should route the stage path to an existing generic LOAD API, or clearly reject an unsupported format before trying an unavailable method. A valid text file that the generic API can load must not fail due to a nonexistent SDK method.

Stability and controls

  • 3 fresh databases × sync/async = 6/6 identical .txt fallback errors.
  • Same-file direct-stage-URL control and recognized .csv batch entry yield exact (1,'alpha'), (2,'beta'), 6/6 each.
  • A nonexistent .csv also yields an error and an empty destination; the failed .txt target stays empty and the client remains usable after the batch. Stage objects are dropped by the fixture.
  • The asynchronous return-of-awaitables behavior was observed but its separate API contract is not asserted here.

Evidence

Reproducible isolated probe and complete results: qsdkaudit4_stage.py, qsdkaudit4_stage.json, qsdkaudit4_stage.log. Each run checks complete destination rows rather than only the return value.

Code analysis

Stage.load_files recognizes four extension groups, then calls LoadDataManager(self._client).from_stage(...) for all remaining filenames. LoadDataManager has no from_stage; from_file explicitly supports stage:// paths. The broad except converts the AttributeError into a per-file error string.

Regression coverage

Test recognized and unrecognized suffixes with an identical valid CSV file, missing file, mixed mappings, synchronous and asynchronous execution; verify complete rows and each per-file result. Confirm failure does not alter the corresponding target.

Related

Open and closed issue/PR searches for load_files and from_stage, and the compatibility-contract LOAD section, found no matching SDK fallback defect. The known LOAD-001 duplicate-key limitation is independent: the reproduction uses unique input keys and fails before a LOAD statement is sent.

Activity

  1. added this to the MO-202610 milestone on Oct 29, 2026
  2. added
    kind/bug
    on Oct 29, 2026
  3. added theissue type on Oct 29, 2026
  4. XuPeng-SH commented on Oct 30, 2026

    @XuPeng-SH
    Contributor

    QA handoff for merged #31774 (main bbfe55669a1440424914d45a283a1d0e36f722fa): please verify the reported public SDK contract and its failure/recovery controls for Python SDK Stage.load_files fallback calls nonexistent from_stage for valid text files. This isolated QA run inspected the issue and merged PR but did not run tests or a live MatrixOne service at this SHA because the existing resource guard left insufficient headroom. The PR's author-reported validation is separate evidence, not a result of this QA run.

  5. slyunnn commented on Oct 30, 2026

    @slyunnn

    Regression and extended verification for #31741 (2026-10-30)

    Verification Environment

    • Requested latest main f6feb84343e4cb949b8ee8063853f86ac99801c6, refactor(sql): consolidate UPDATE target ownership (#31798), is unbuildable due to #31812. The requester approved earlier main 43c6d84741d60838c28d2b93ab8ad4b6f922a678, fix(python): enforce CSV export format and preserve user account metadata (#31802), which contains the fix.
    • Fresh Go 1.27.1 service build; binary module identity and live git_version() confirm 43c6d84741. Same-commit Python SDK, Python 3.14, SQLAlchemy 1.4.54, 2.0.55, 2.1.6.
    • Native macOS/arm64 single-host 2 CN / 1 TN / 1 Log service / Proxy. Proxy localhost:6001, CN1 localhost:16001, CN2 localhost:16002 all reachable and all executed actual file loads. Sync SDK/SQLAlchemy/PyMySQL and async SDK/SQLAlchemy/aiomysql over MySQL text protocol; Stage files are available to the owned local services.

    What Was Covered

    • OK — Mixed Stage.load_files mappings containing .csv, .txt, .dat, a filename without extension and a missing .txt. All 72 valid-file loads across versions, sync/async and endpoints restore the exact expected 2 rows per target.
    • OK — Direct load_data.from_file('stage://.../data.txt', ...) controls restore identical rows. Empty mappings return an empty result mapping.
    • OK — Missing-file handling in all 18 combinations: sync returns the per-file error string; async returns an awaitable which raises the actual loading error when awaited. Failed targets stay empty, remaining files load, and no nonexistent from_stage call occurs.
    • OK — Connection reuse, 0 checked-out connections, Stage removal and database removal verified; final catalog checks find no owned residue.
    • OK — Pre-fix SDK c6683bd2f531dcaa80e153c0924dac619c49dc9d reproduces LoadDataManager has no attribute 'from_stage' on the same server.
    • Not covered — S3/production object storage, JSON/Parquet parsing or a new async batch return-shape contract. The issue concerns generic text-file fallback, not those independent surfaces.

    Findings

    PR #31774, merge bbfe55669a1440424914d45a283a1d0e36f722fa, fix(python): unify SDK query and analytics lifecycle contracts, routes generic suffixes through the existing from_file loader. Valid fallback loads work and genuine file errors remain observable per the existing sync/async contract. The missing-file error is expected (20301), not a regression.

    MOTR / BVT Coverage

    Reused clients/python/tests/offline/test_stage.py, with real SDK/server/file integration above. The shared three-file SDK contract selection passed 171 tests on each SQLAlchemy version; these are not all Stage-specific tests. No duplicate SQL-only MOTR coverage, source change, commit or PR was required. Runs were serial across issues and fixture/version resets to isolate Stage/catalog state.

    Final Conclusion

    Fixed on verified main/SDK 43c6d84741; no passing-runtime claim for unbuildable f6feb84343. Large-data regression is not needed: extension dispatch and per-file error propagation are independent of file size; 2 rows suffice to detect omission and incorrect routing. The issue remains open for maintainer acceptance.

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

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions