Skip to content

fix(plugin): oneOf nullable outputs; reject non-array filter and unknown spec keys - #6

Merged
MonSp merged 5 commits into
mainfrom
fix/v0.1.5-tool-defects
Nov 2, 2026
Merged

MonSp merged 5 commits into
mainfrom
fix/v0.1.5-tool-defects

Conversation

@MonSp

@MonSp MonSp commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Fixes the tool-layer defect list from dsh-analyze-v015-defects.md (v0.1.4 / v0.1.5 联调), plus all review follow-up items from rounds 1 and 2 (blocker, items 1–3, and round-2 should-fixes; both in multi-value and the escape-aware scanners were folded in instead of opening issues). No version bump — release numbering is left for the maintainer (CHANGELOG records everything under Unreleased).
  • BUG-1 / BUG-2 — nullable outputs (outDatasetId / stratifyBy / label) are declared oneOf: [{type:'string'},{type:'null'}] instead of JSON Schema type arrays or plain string. Tools now register on DSH hosts (no UNSUPPORTED_SCHEMA) and CLI null values pass output validation. dataset_list declares parentDatasetId (string | null) and sourceKind; dataset_dedup declares keyColumns (string[] | null).
  • BUG-3 — a non-array filter (object / string / {}) used to be silently dropped and the full table returned with ok:true. validateAggSpec and the Rust CLI now reject it with analysis/invalid-args: filter must be an array; wrong-shape select / mutate / groupBy / aggs / orderBy / limit and unknown top-level spec keys are rejected the same way (CLI exit 2, never a silent full-table result).
  • Nested keys never shadow top-level fields — find_key is depth- and string-aware, so key order cannot change results ({"filter":[{...,"limit":2}],"limit":1} both orders use the top-level limit).
  • limit enforced at parse — integer 1..5000 or exit 2, instead of silently clamping. Error texts unified across layers: type → limit must be a number, range → limit must be an integer 1..5000.
  • filter value shapes + in multi-value — value is required for every op except is_null / not_null; only op: "in" accepts an array and every member matches (OR via values_eq; scalar = one-member set, [] = empty set); arrays for other ops and non-scalar members are rejected. Front-line checks also cover filter column, select entries, and orderBy items.
  • One number lexer for every path — extract_number and the in member parser share lex_number: exponents (2e1, 3e3) parse as JSON numbers everywhere (limit, filter value, in scalar/array), and trailing junk (2abc) is rejected instead of silently reading a prefix (2e1 used to become 2 on the scalar paths while JSON.parse on the tool layer read 20).
  • String-aware extraction everywhere — extract_array brackets, split_top_objects item splitting, and parse_string_array elements all track strings and escapes: ] in select ["A]B"] no longer truncates, and \" inside an item string no longer swallows later filter / aggs / orderBy / mutate items (a swallowed second filter returned the whole table).
  • orderBy.desc must be a boolean on the CLI too (was silently false; the tool layer already rejected it).
  • BUG-4 / BUG-5 — docs/interface.md documents nullable fields as string | null and adds a "Spec key shapes" section covering filter array, value-shape, column, desc, and limit contracts; the transform_agg spec description spells out filter and value shapes with examples.

Verification

  • cargo test -p dsh-analyze — 67/67 green (25 unit tests, 10 cli_agg.rs integration tests against the real binary, plus 32 quality/relation/series integration tests). New regressions in this round: 2e1/3e3 exponents on every path, 2abc → exit 2 bad number, escaped-quote filter items keep the second filter (rowCount 1, not the full table), orderBy.desc:"true" → exit 2.
  • node --test tests/analysis-*.test.mjs — 56/56 green: schema self-check (no type arrays), nullable/oneOf field declarations (incl. keyColumns), mock-CLI null outputs (incl. dedup exact keyColumns:null) pass output-schema validation, and every wrong-shape key / value / limit error is rejected before CLI spawn.
  • tsc clean; dist/ rebuilt.
  • Manual note: the BUG-1/2 host behavior (UNSUPPORTED_SCHEMA, output validation) comes from the Investigator-side real DSH 联调 that produced the defect list. A final real-host smoke (register + one call per nullable-output tool) is recommended before release; this PR's automated verification is mock CLI + real dsh-analyze binary.

@MonSp
MonSp merged commit 4652f10 into main Nov 2, 2026
5 checks passed
@MonSp
MonSp deleted the fix/v0.1.5-tool-defects branch November 2, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant