Skip to content

[Bug]: fulltext create_index swallows server errors with print() #31382

Closed

Description

@Ariznawlll

DRAFT 7 (SDK, 2026-10-27) — candidate issue, not yet filed

Title: [Bug]: FulltextIndex.create_index swallows server errors with print() and always reports clean failure; algorithm parameter silently ignored

Description

(The algorithm-ignored half of this report is adjacent to #31219 — CLOSED, which covered the with_algorithm/BM25 builder path. The un-filed core of this report is the error swallowing in the same create_index/drop_index call path: the server's real error never reaches the caller, and the ignored algorithm is listed only as context.)

FulltextIndex.create_index/drop_index (matrixone/sqlalchemy_ext/fulltext_index.py) catch every server exception and turn it into a stdout print plus a False return:

except Exception as e:
    print(f"Failed to create fulltext index: {e}")
    return False

The caller chain makes it worse — FulltextIndexManager.create() (fulltext_manager.py:~165) then just does:

if not success:
    raise QueryError(f"Failed to create fulltext index {name} on table {table_name}")

So the server's actual error text never reaches the API user: they get a generic "Failed to create fulltext index" (with names only) while the real cause (syntax error, privilege, duplicate index, experimental flag off — SET experimental_fulltext_index is required per _build_enable_sql) went to stdout, invisible in any app that doesn't watch the console. In server environments (aiohttp/FastAPI workers), the print is lost entirely.

Second defect in the same API: the algorithm parameter is accepted and ignored. The docstring says "stored for reference, not in DDL" but the module docstring of FulltextIndexManager advertises client.fulltext_index.create("documents", "idx_content", "content", algorithm="BM25") as creating a BM25 index. The correct server mechanism exists (SET ft_relevancy_algorithm = "BM25" per the create_index docstring) but the code never issues that SET — so BM25-requesting users silently get default TF-IDF ranking; search relevance differs from the documented behavior with no warning.

Thirdly the DDL itself is unescaped f-string interpolation: f"CREATE FULLTEXT INDEX {name} ON {table_name} ({columns_str})" — part of the escaping family already filed this round; listed for completeness, main content of this issue is the error-swallowing + ignored algorithm.

Reproduction

client.fulltext_index.create("articles", "bad_name!", ["col'"])  # invalid identifier
# server: clear 1064-ish error with position info
# SDK user sees: QueryError("Failed to create fulltext index bad_name! on table articles")
# console (if watched): the real error — one print() line
# no exception chaining (raise ... from None semantics via the except-swallow), no logger use

BM25:

client.fulltext_index.create("docs", "ft", "body", algorithm="BM25")
# DDL executed: CREATE FULLTEXT INDEX ft ON docs (body)   ← no algorithm anywhere
# ranking behaves as TF-IDF

Impact

  • Diagnosing fulltext failures from application logs is impossible (the only real error is a print to stdout).
  • The heavy try/except Exception also masks programming errors (wrong bind type, missing connection attr) as "Failed to create".
  • BM25 users get worse relevance with zero signal — hard-to-debug search-quality complaints.

Expected behavior

  1. create_index/drop_index should raise (or return (ok, error)); at minimum preserve the server message and chain (raise QueryError(...) from e), and use the SDK logger, never print().
  2. Honor algorithm: issue SET ft_relevancy_algorithm = <algorithm> on the bind before creating the index (and restore the prior value after), or raise NotImplementedError("algorithm is not applied; use SET ft_relevancy_algorithm manually") so the parameter stops being decorative. Reconcile the module docstring examples as well.
  3. Escape identifiers in the DDL (tracked with the escaping-family issue already filed — [Bug]: SDK _escape_string/_escape_identifier are no-ops that only wrap quotes #31375/[Bug]: single-row _build_insert_sql does not escape quotes, crashes on batch key mismatch, quotes numerics #31376).

Activity

  1. added
    kind/bug
    on Oct 27, 2026
  2. added this to the MO-202610 milestone on Oct 27, 2026
  3. added theissue type on Oct 27, 2026
  4. added a commit that references this issue on Oct 30, 2026
    bbfe556
  5. 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 fulltext create_index swallows server errors with print(). 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.

  6. Ariznawlll commented on Oct 30, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    测试通过。全文索引操作失败时 SDK 保留服务端错误作为异常原因;不支持的 BM25 索引参数明确拒绝,不再被静默忽略。

    关键证据

    • 官方 main@d39d8a40343ccd40bf665036388df7a40ee867f8;修复 PR fix(python): unify SDK query and analytics lifecycle contracts #31774 合并提交 bbfe55669a1440424914d45a283a1d0e36f722fa 位于祖先链;实际二进制与 SDK 同完整 SHA。本地隔离 1 CN / 1 TN / 1 LogService,Python 3.12。
    • 三个独立库:有效全文索引创建成功并在元数据中可见;对不存在的列创建索引以及删除不存在的索引均抛 QueryError,异常原因保留对应的服务端列名或索引名,未向 stdout 打印错误。
    • 创建索引时传 BM25 被明确拒绝,错误原因说明排序需在查询侧配置;失败后原表两行内容不变、连接可用,每轮测试库清理。针对全文索引的 SDK 离线测试 15/15 通过。
    • 回归已加入 MOTR #295,定向 3/3 通过、0 skipped。

    待解决点

  7. Ariznawlll commented on Oct 30, 2026

    @Ariznawlll
    CollaboratorAuthor

    回归位置更正:#295 已关闭并汇总至 MOTR #298,该 issue 的定向用例已包含在 #298。此前测试证据与未覆盖项不变;#298 尚未合入,完整 MOTR suite 未运行。

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