Repository navigation
CXH-4061: fix MySQL []byte CEL comparisons dropping grants - #160
c1-squire-dev[bot] wants to merge 3 commits into
Conversation
… so MySQL CEL comparisons work Add normalizeRowValue and apply it at the runQuery row-map construction site so []byte driver values reach CEL as strings; NULL stays nil. Pass SyncInputs(rowMap) to the replace-path SkipIf EvaluateBool so column expressions are visible there, and revert the mysql-test.yml grant skip_if to the plain form. Adds chokepoint, NULL-semantics, replace-path and identity-pin tests. Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
…n the BLOB chokepoint test Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
…al review Round-1 review fix-nows: assert both fixture rows are visited in the BLOB chokepoint test (closes the u1-branch false-pass window); correct the typed-nil comment (no supported driver delivers NULL as typed-nil []byte — database/sql reports NULL as untyped nil); pin that normalized columns compare as CEL strings, so bytes literals no longer match a row column (the deliberate consequence of normalization, named for the PR body). Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
Superseded — see the current review report for commit
|
Connector PR Review: CXH-4061: fix MySQL []byte CEL comparisons dropping grantsBlocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0 Review SummaryWhat changed
Coverage
No dependency manifests changed. Repo-local criteria
Tests Security IssuesNone found. Correctness IssuesNone found. SuggestionsNone. Reviewed commit: |
There was a problem hiding this comment.
No blocking issues found — see the full review report
CXH-4061: normalize MySQL
[]bytedriver values to strings at the CEL boundaryLinear: https://linear.app/ductone/issue/CXH-4061/baton-sql-fix-mysql-text-columns-comparing-unequal-in-cel-dropping-every-grant
What was asked
On MySQL, every non-numeric column reaches CEL as
[]byte(go-sql-driver/mysqltext and binaryprotocols), so a CEL comparison between a row value and a string literal is never equal. A
skip_ifof the form.column != resource.IDis true for every row: every grant is skipped andthe sync exits 0 with no warning — silent data loss worse than a crash. The repo's own
examples/mysql-test.ymlships exactly that construct as its only MySQL grant mapping, and theticket measured 0 grants on 6 live
user_rolesrows; addingstring(.role_name)to that one tokenyielded 7 grants. PostgreSQL, SQL Server and Vertica already work because their drivers return
strings. The ask: normalize MySQL
[]byterow values tostringat the single point where rowvalues cross into CEL, so user-authored comparisons compare strings on every driver, and preserve
NULL semantics (a NULL column must stay Go
nil, never"NULL"or"").What changed
One seam, three code touches, tests, and a one-line example revert:
pkg/bsql/query.go—normalizeRowValue(v any) any(unexported, placed beside the existing[]byteprecedentsnextPageTokenandtoTime): two-value assertionv, ok := v.([]byte)converts byte slices to strings; untyped
nil(a NULL column) falls through untouched, so== nullguards keep working by construction.runQuery):rowMap[colName] = normalizeRowValue(values[i])— thesingle boundary every CEL hand-off crosses, covering all five
EvaluateBoolchokepoints(grants, expandable grants, entitlements, event feed, provisioning replace) and every
EvaluateStringternary. Pagination'slastRowIDis deliberately left raw —nextPageTokenalready handles both
[]byteandstring.SkipIfnow evaluates againsts.env.SyncInputs(rowMap)like every other site, instead of the raw row map (which madeEvaluateinject an empty
cols, so replace-pathskip_ifcould not see columns at all). Expressionsreferencing
resourcestill fail loudly there —resourceis derived after the skip check —and that failure stays a wrapped error, not a silent skip.
examples/mysql-test.yml: the grantskip_ifreverts to the plain form.role_name != resource.ID(thestring()workaround thatCXP-481introduced is no longerneeded), matching every other engine's example.
[]byte→string, untypednil→nil, typed-nil slicepinned); a chokepoint test through the real
rows.Scanpath (SQLite BLOB-typed column = theMySQL-shaped
[]byteinput) asserting the plain-formskip_ifstops skipping and a NULL columnmatches only
== null; NULL-semantics pins in the CEL package; provisioning replace-path tests(columns now visible;
resource-referencing skip_if still errors loudly); identity pins provingstring/int64/float64/bool/time.Time values pass through unchanged; and a guard pinning the
example's plain form. The chokepoint test was mutation-checked: reverting the normalize line
makes it fail.
How far this is verified
validate-changes.sh(build + vet + test scoped to the touchedpackages
pkg/bsqlandpkg/bcel) passes, including the new tests and the existing paginationsuite. Five independent implementations of the same specification were built and adversarially
reviewed in isolated worktrees; this branch is the ranked winner, and its chokepoint test was
mutation-checked to prove it fails without the fix (re-verified independently during review).
exact head (
b656cdc5) with no unresolved threads.environment and raised zero findings; it re-enumerated every CEL hand-off, verified
identifier outputs stay byte-for-byte identical, and reproduced the mutation check itself.
honestly UNTESTABLE — the live MySQL wire measurement (7 grants from 6 rows) needs a running
MySQL this repo does not provide; that evidence is CI's MySQL engine tests, which are green.
exposes no runnable mock, so nothing was started end to end.
no baseline sync comparison exists for this repo.
What to look at hardest
[]byte-returning engines, all reviewed and accepted as the fix'sintent: (1) bytes-literal equality and
size()on byte-typed columns now compare as CELstrings — a spec that used
== b'...'on such a column previously content-matched bytes andnow never matches (write the comparison against the string form, or use
bytes());.size()becomes a rune count on multi-byte text; (2)
grantRowKeyformats byte-typed event-feedprimary keys differently (byte-list
%vform → plain string) — IDs remain injective and cursorstate is unaffected, but one deploy transition may re-emit a round of change events; (3) a
typed-nil
[]byte(driver quirk, distinct from a NULL column) normalizes to""— pinnedexplicitly in tests.
future edit can break. Tests pin
== nulltrue and== ""/== "NULL"false.parseTimedeliberately not added), no CEL-library change,no resource/entitlement/ID representation change — emitted values are byte-for-byte identical;
only CEL's input type changes.