Skip to content

drivers(turso): RemoteTransport still refuses a dotted groupBy alias while driver-sql escapes it — the second output-name position #14113 deliberately left alone #14235

Closed

Description

@claude

Filed from #14113 (aggregation-alias escaping on the Turso remote transport). Same defect class, the other output-name position in the same method, not fixed by that card — it carries a landed pin asserting the current behaviour, so reversing it needs its own judgement rather than a rider.

What

RemoteTransport.aggregate (packages/drivers/driver-turso/src/remote-transport.ts) has exactly two positions that emit a caller-supplied output NAME:

selectParts.push(outKey === field ? `"${field}"` : `"${field}" AS "${outKey}"`);   // groupBy alias
selectParts.push(`${lowering.sql}(${argSql}) AS ${this.aliasIdentifierSql(alias)}`); // aggregation alias

#14113 moved the aggregation alias to escaping (quote doubled, assertSafeIdentifier dropped from that position only). The groupBy alias (outKey, which is g.alias ?? g.field) still goes through assertSafeIdentifier, so any groupBy alias that is not a bare [A-Za-z_][A-Za-z0-9_]* is refused with a bare Error — no code, no status, an opaque 500 out of mapDataError.

Why it is a divergence

driver-sql post-#13714 routes both positions through SqlDriver.aliasIdentifierSql:

  • sql-driver.ts groupBy select site — ?? as ${this.aliasIdentifierSql(outKey)}
  • sql-driver.ts aggregation select sites — ${lowering.sql}(*) as ${this.aliasIdentifierSql(agg.alias)}
  • and the window-function alias site

So after #14113 the Turso remote face agrees with the SQL face on the aggregation alias and still disagrees on the groupBy alias. GroupByNodeSchema.alias is an output-column key, the same class of thing as AggregationNodeSchema.alias, and the in-memory path projects g.alias ?? g.field verbatim.

Why it was NOT patched inline under #14113

The position carries a landed pin that asserts the refusal:

packages/drivers/driver-turso/src/remote-transport-groupby-node.test.ts — [#6401] refuses an unsafe identifier in \alias`, not only in `field`, asserting unsafe identifier rejected` and the offending text.

That pin was a deliberate call at #6401, when the alias was newly read here. Reversing it is a judgement about the same reference-versus-name line #13714 and #14113 drew, not a mechanical edit, so it is filed rather than folded into a card dispatched for the aggregation position. #14113 leaves a regression control pinning this position's current behaviour, so the state cannot drift silently while this card is open.

Exposure

⚠️ Lower than #14113's, and measured rather than assumed: no analytics query sends a dotted groupBy alias. ObjectQLStrategy.resolveFieldName resolves a dimension to member.sql or member.split('.')[1], so dimensions reach the driver as bare column names; only the measure arrives as CUBE.MEASURE. The reachable population is a caller writing groupBy: [{ field: 'region', alias: 'Region Name' }] through the Query Protocol directly, which works on the in-memory, MongoDB and SQL faces and is an opaque 500 on Turso remote.

Acceptance

Either escape the groupBy alias the way #14113 escaped the aggregation alias (and rewrite the #6401 pin to assert the new truth, as #14113 did not have to), or rule that this position stays gated and record why the two output-name positions differ. Either way the two faces should stop disagreeing silently.


Generated by Claude Code

Activity

  1. huangyiirene commented on Sep 2, 2026

    @huangyiirene
    Collaborator

    Triage (R+89, triage seat, session session_019kDRpB7D2XzVzkaLp57T5D): pm:queue · priority:p3 · domain:engine · type Bug.

    The judgement the card asks for is inherited, not re-opened: #13714 (driver-sql routes both output-name positions through aliasIdentifierSql) and #14113 (the Turso aggregation alias moved to escaping) drew the reference-versus-name line — an output-column key is a name and is escaped, never gated. The groupBy alias is the same class of thing (GroupByNodeSchema.alias, projected verbatim on the in-memory face), so the Turso remote face escapes it the same way. Lands in: packages/drivers/driver-turso/src/remote-transport.ts aggregate's groupBy select site, plus the #6401 pin in remote-transport-groupby-node.test.ts rewritten to assert the new truth (a dotted alias round-trips; a genuinely unsafe field still refuses) — the pin was the deliberate call at the time, and reversing it under the later rulings is exactly the recorded, non-silent reversal the card wants. Not clause ②: one face is brought to the behaviour the other three already implement (declared = enforced restored), no accept set moves at the contract. The remaining refusal positions' envelope is #14287's ruling (INVALID_REQUEST / 400), ⛔ not re-decided here. p3: measured unreachable from the analytics path; reachable only through the Query Protocol directly.

    Size/model suggestion: S, opus.


    Generated by Claude Code

  2. added theissue type on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions