Skip to content

[codex] Refactor enum handling through domain commands#243

Open
eviltester wants to merge 21 commits into
masterfrom
codex/228-improve-command-definition
Open

[codex] Refactor enum handling through domain commands#243
eviltester wants to merge 21 commits into
masterfrom
codex/228-improve-command-definition

Conversation

@eviltester

@eviltester eviltester commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

Refactors enum handling so public enum spellings normalize into the domain command execution model via datatype.enum, while preserving enum(...) as the canonical emitted schema text.

Also rationalizes the schema interaction matrix coverage by removing static matrix/parity fixtures and the broad app-vs-generator parity sweep, keeping generated runtime coverage plus small app/generator page-wiring smoke suites.

Closes #228.

Validation

  • pnpm test -- packages/core-ui/src/tests/interaction/matrix/schema-interaction-scenario-builder.test.js packages/core-ui/src/tests/interaction/matrix/schema-interaction-runtime-matrix.test.js packages/core-ui/src/tests/interaction/matrix/app-schema-interaction-matrix.test.js packages/core-ui/src/tests/interaction/matrix/generator-schema-interaction-matrix.test.js packages/core-ui/src/tests/interaction/matrix/deterministic-scenario-seed.test.js
  • pnpm run verify:local
  • pnpm run verify:ui
  • pre-push pnpm run verify:local

Summary by CodeRabbit

  • New Features
    • Added datatype.enum as a first-class keyword with dedicated help/usage, validation, and variadic values support.
    • Improved enum handling so multiple syntaxes compile and generate consistently to the canonical datatype.enum(...) form.
  • Bug Fixes
    • Fixed enum parsing/normalization across compilation, generation, and schema validation, including enum-like detection and context-driven value extraction.
  • Tests
    • Updated interaction matrix suites to use in-memory page-wiring smoke subsets (removed parity sweeps/fixtures) and adjusted timeouts where needed.
  • Documentation
    • Updated the frontend UI matrix rationalization plan and exit criteria.

Copilot AI review requested due to automatic review settings June 24, 2026 11:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds datatype.enum support across core and core-ui, canonicalizes enum rule specs, and removes the UI parity sweep in favor of separate smoke suites and runtime coverage.

Changes

Enum Canonicalization and Parity Retirement

Layer / File(s) Summary
Keyword metadata and domain wiring
packages/core/js/domain/domain-command-metadata.js, packages/core/js/domain/domain-keywords.js, packages/core/js/domain/parser/DomainKeywordParser.js, packages/core/js/keywords/domain/datatype/datatype-enum.js, packages/core/js/keywords/domain/datatype/enum-keyword-definition.js, packages/core/js/keywords/domain/datatype/datatype-keyword-definitions.js, packages/core-ui/js/gui_components/shared/domain-command-help-metadata.js, packages/core-ui/js/gui_components/shared/domain-commands.js, packages/core/js/command-help/command-help-validators.js
Adds datatype.enum keyword definition, executor, catalog registration, variadic arg handling, and core domain command metadata with core-ui re-exports.
Core enum canonicalization pipeline
packages/core/js/data_generation/utils/enumParser.js, packages/core/js/data_generation/testDataRulesCompiler.js, packages/core/js/data_generation/rulesBasedDataGenerator.js, packages/core/js/data_generation/n-wise/pairwiseTestDataGenerator.js, packages/core/js/data_generation/schema-rules-adapter.js, packages/core/js/data_generation/schema-conversion.js, packages/core/js/data_generation/rulesParser.js, packages/core/js/data_generation/schema-constraint-validator.js, packages/core/src/tests/data_generation/*, packages/core/src/tests/data_generation/unit/*
Adds enum canonicalization helpers and updates compiler, generator, adapter, conversion, rendering, and validation paths to treat enum inputs as canonical domain or schema forms.
core-ui enum mapping and schema widgets
packages/core-ui/js/gui_components/shared/test-data/generation/generation-controller.js, packages/core-ui/js/gui_components/shared/test-data/schema/schema-row-mapper.js, packages/core-ui/js/gui_components/shared/test-data/schema/schema-runtime.js, packages/core-ui/src/tests/shared/*, packages/core-ui/src/tests/utils/params-editor-modal.test.js, packages/core-ui/src/tests/grid/schema/test-data-schema-grid-engine-compat.test.js, packages/core-ui/src/tests/interaction/app-test-data-focused-generation.test.js
Updates core-ui generation and schema mapping for canonical enum rules and adjusts related help, params, and schema-widget tests.
Parity retirement and generated smoke scenarios
packages/core-ui/src/tests/interaction/matrix/support/schema-interaction-matrix-formatting.js, packages/core-ui/src/tests/interaction/matrix/support/schema-interaction-scenario-builder.js, packages/core-ui/src/tests/interaction/matrix/app-schema-interaction-matrix.test.js, packages/core-ui/src/tests/interaction/matrix/generator-schema-interaction-matrix.test.js, packages/core-ui/src/tests/interaction/matrix/schema-interaction-runtime-matrix.test.js, docs/frontend-ui-matrix-rationalization-plan.md
Removes parity sweep artifacts, switches matrix tests to in-process scenario builders, narrows the report helper exports, and updates the plan document to describe the retired parity flow.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~90 minutes

Possibly related PRs

Poem

🐇 I hopped through enums, neat and bright,
And made old parity take flight.
datatype.enum now sings in tune,
With smoke suites blooming under the moon.
Old fixtures fade, the paths are clear —
This bunny leaves a cleaner trail here.

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR adds extensive enum normalization and matrix-fixture cleanup that are unrelated to the linked command-definition maintenance issue. Split the enum/matrix refactors into separate PRs or link their issues so the scope matches #228.
Docstring Coverage ⚠️ Warning Docstring coverage is 1.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive The PR moves command help into domain metadata, but the context doesn't confirm the required faker-command-help-metadata removal or domain-faker-module-keyword-definitions adoption. Verify the consumers were updated to domain-faker-module-keyword-definitions.js and that faker-command-help-metadata.js was removed or reduced as required.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main enum-handling refactor, even though it omits the matrix cleanup.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/228-improve-command-definition

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45626bae67

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/js/keywords/domain/datatype/enum-keyword-definition.js Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/core-ui/src/tests/interaction/matrix/app-schema-interaction-matrix.test.js`:
- Around line 32-35: The smoke scenario selection in
app-schema-interaction-matrix.test.js currently hides missing scenario IDs by
filtering out falsy results, which can silently shrink coverage. Update the
scenario resolution logic around buildUiInteractionScenarios,
findScenarioByLogicalId, and SMOKE_SCENARIO_IDS to fail fast when any ID cannot
be found, instead of using filter(Boolean). Keep the suite generation strict so
a renamed or missing logical ID immediately surfaces as a test failure.

In
`@packages/core-ui/src/tests/interaction/matrix/generator-schema-interaction-matrix.test.js`:
- Around line 32-35: The smoke matrix setup in
generator-schema-interaction-matrix.test.js is silently dropping missing entries
because `SMOKE_SCENARIO_IDS.map(...).filter(Boolean)` hides absent scenarios.
Update the scenario selection around `buildUiInteractionScenarios`,
`findScenarioByLogicalId`, and `SMOKE_SCENARIO_IDS` to fail fast instead: detect
when any curated smoke scenario id cannot be resolved and throw an explicit
error or assertion before building `scenarios`, rather than filtering it out.

In
`@packages/core-ui/src/tests/interaction/matrix/support/schema-interaction-matrix-report.js`:
- Line 54: The report-helper module export list is out of sync with the
generator script: `scripts/generate-schema-interaction-matrix.mjs` still depends
on `renderMatrixSummaryMarkdown` from `schema-interaction-matrix-report.js`.
Restore a compatibility export for `renderMatrixSummaryMarkdown` in that module,
or update the generator script to stop importing it and use the new API, so both
`buildChunkDescriptors` and `formatCommandsForConsole` remain available without
breaking the summary artifact flow.

In `@packages/core/js/data_generation/rulesParser.js`:
- Around line 242-244: The enum rule rendering in rulesParser.js only
canonicalizes datatype.enum(...) and can leave awd.datatype.enum(...) unchanged,
so update the renderer to normalize all supported enum function spellings before
output. In the code paths using EnumParser.isCanonicalDomainEnumRuleSpec and
EnumParser.normalizeToCanonicalSchemaRuleSpec, extend the check/normalization
logic so older awd.datatype.enum(...) inputs also map to the canonical enum(...)
form, and apply the same fix in both affected rendering locations in
rulesParser.js.

In `@packages/core/js/data_generation/schema-conversion.js`:
- Around line 16-18: Broaden the enum normalization in the schema conversion
path so legacy enum spellings are canonicalized too. Update the conditional
around `EnumParser.isCanonicalDomainEnumRuleSpec` in `schema-conversion.js`, and
the matching logic at the other enum handling site, so both `datatype.enum(...)`
and legacy `awd.datatype.enum(...)` are rewritten through
`EnumParser.normalizeToCanonicalSchemaRuleSpec`. This will keep schema emission
consistent with the expanded enum parsing surface and ensure round-tripped
schemas always use `enum(...)`.

In `@packages/core/js/data_generation/schema-rules-adapter.js`:
- Around line 95-97: The domain enum handling in normaliseFakerCommand currently
only matches datatype.enum after lowercasing, so awd.datatype.enum falls through
and serializes incorrectly. Update the condition around
buildEnumRuleSpec(params) to also recognize the awd.datatype.enum alias (or
normalize it before the check) so SOURCE_TYPE_DOMAIN enum rows follow the same
enum rule path consistently.

In `@packages/core/js/data_generation/testDataRulesCompiler.js`:
- Around line 73-74: The compile() flow in testDataRulesCompiler.js only
normalizes enum rules in the auto-detected branch, so predeclared rules with
type set to enum can still bypass canonicalization and produce mixed enum/domain
representations. Update compile() so it also routes the declared-type enum path
through the same normalization logic used by
EnumParser.normalizeToCanonicalDomainRuleSpec, and ensure the rule.type is
consistently set to the canonical domain form when ruleSpec is normalized.

In `@packages/core/js/data_generation/utils/enumParser.js`:
- Around line 61-72: The canonical domain-enum check in
EnumParser.isCanonicalDomainEnumRuleSpec is too loose because it only matches
the datatype.enum( prefix, so malformed ruleSpec strings can still be classified
as enum-like. Tighten this helper to validate the full invocation syntax
end-to-end, and keep EnumParser.isEnumLikeRule aligned with that stricter check.
This will prevent schema-constraint-validator from passing invalid domain rules
into EnumParser.extractEnumValues and turning validation errors into exceptions.

In `@packages/core/js/keywords/domain/datatype/datatype-enum.js`:
- Around line 5-14: The enum argument normalizer is double-wrapping already
formatted input, causing `enum(active,inactive)` to become
`enum(enum(active,inactive))` and break parsing. Update
`validateDatatypeEnumArgs` and the normalization path in `datatype-enum.js` to
detect when the single string argument is already function-shaped (for example,
already starts with `enum(` and ends with `)`) and pass it through unchanged
before calling `EnumParser.extractEnumValues`, so existing enum syntax is parsed
directly instead of wrapped again.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ff4bf96b-fdb3-40a5-9303-b03e76b109cd

📥 Commits

Reviewing files that changed from the base of the PR and between 32e6729 and 45626ba.

📒 Files selected for processing (45)
  • apps/web/src/tests/browser/generator/functional/schema-edit.spec.js
  • docs/frontend-ui-matrix-rationalization-plan.md
  • packages/core-ui/js/gui_components/shared/domain-command-help-metadata.js
  • packages/core-ui/js/gui_components/shared/domain-commands.js
  • packages/core-ui/js/gui_components/shared/test-data/generation/generation-controller.js
  • packages/core-ui/js/gui_components/shared/test-data/schema/schema-row-mapper.js
  • packages/core-ui/js/gui_components/shared/test-data/schema/schema-runtime.js
  • packages/core-ui/src/tests/grid/schema/test-data-schema-grid-engine-compat.test.js
  • packages/core-ui/src/tests/interaction/app-test-data-focused-generation.test.js
  • packages/core-ui/src/tests/interaction/matrix/app-schema-interaction-matrix.test.js
  • packages/core-ui/src/tests/interaction/matrix/fixtures/schema-interaction-matrix-summary.md
  • packages/core-ui/src/tests/interaction/matrix/fixtures/schema-interaction-matrix.json
  • packages/core-ui/src/tests/interaction/matrix/fixtures/ui-scenario-parity.json
  • packages/core-ui/src/tests/interaction/matrix/generator-schema-interaction-matrix.test.js
  • packages/core-ui/src/tests/interaction/matrix/schema-interaction-matrix-report.test.js
  • packages/core-ui/src/tests/interaction/matrix/schema-interaction-runtime-matrix.test.js
  • packages/core-ui/src/tests/interaction/matrix/support/schema-interaction-matrix-report.js
  • packages/core-ui/src/tests/interaction/matrix/support/ui-scenario-parity.js
  • packages/core-ui/src/tests/interaction/matrix/ui-scenario-parity-fixture.test.js
  • packages/core-ui/src/tests/interaction/matrix/ui-scenario-parity-support.test.js
  • packages/core-ui/src/tests/interaction/matrix/ui-schema-interaction-parity.test.js
  • packages/core-ui/src/tests/shared/generation-controller.test.js
  • packages/core-ui/src/tests/shared/schema-runtime.test.js
  • packages/core/js/command-help/command-help-validators.js
  • packages/core/js/data_generation/n-wise/pairwiseTestDataGenerator.js
  • packages/core/js/data_generation/rulesBasedDataGenerator.js
  • packages/core/js/data_generation/rulesParser.js
  • packages/core/js/data_generation/schema-constraint-validator.js
  • packages/core/js/data_generation/schema-conversion.js
  • packages/core/js/data_generation/schema-rules-adapter.js
  • packages/core/js/data_generation/testDataRulesCompiler.js
  • packages/core/js/data_generation/utils/enumParser.js
  • packages/core/js/domain/domain-command-metadata.js
  • packages/core/js/domain/domain-keywords.js
  • packages/core/js/domain/parser/DomainKeywordParser.js
  • packages/core/js/keywords/domain/datatype/datatype-enum.js
  • packages/core/js/keywords/domain/datatype/datatype-keyword-definitions.js
  • packages/core/js/keywords/domain/datatype/enum-keyword-definition.js
  • packages/core/src/tests/data_generation/domain-generation-path.test.js
  • packages/core/src/tests/data_generation/enum-compiler-integration.test.js
  • packages/core/src/tests/data_generation/enum-format-bug-fix.test.js
  • packages/core/src/tests/data_generation/enum-surface-parity.test.js
  • packages/core/src/tests/data_generation/mixed-compiler-integration.test.js
  • packages/core/src/tests/data_generation/unit/domain/domain-command-metadata.test.js
  • packages/core/src/tests/data_generation/user-reported-bug-http-method.test.js
💤 Files with no reviewable changes (6)
  • packages/core-ui/src/tests/interaction/matrix/schema-interaction-matrix-report.test.js
  • packages/core-ui/src/tests/interaction/matrix/ui-scenario-parity-support.test.js
  • packages/core-ui/src/tests/interaction/matrix/support/ui-scenario-parity.js
  • packages/core-ui/src/tests/interaction/matrix/ui-scenario-parity-fixture.test.js
  • packages/core-ui/src/tests/interaction/matrix/ui-schema-interaction-parity.test.js
  • packages/core-ui/src/tests/interaction/matrix/fixtures/ui-scenario-parity.json

Comment thread packages/core/js/data_generation/rulesParser.js Outdated
Comment thread packages/core/js/data_generation/schema-conversion.js Outdated
Comment thread packages/core/js/data_generation/schema-rules-adapter.js Outdated
Comment thread packages/core/js/data_generation/testDataRulesCompiler.js
Comment thread packages/core/js/data_generation/utils/enumParser.js
Comment thread packages/core/js/keywords/domain/datatype/datatype-enum.js
@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR refactors enum handling so all public spellings (enum(...), datatype.enum(...), awd.datatype.enum(...), shorthand, implicit CSV) normalise through the domain command execution model, while retaining enum(...) as the canonical emitted schema text. It also removes static matrix fixtures and the app-vs-generator parity sweep in favour of runtime-generated interaction coverage.

  • Core change: EnumParser gains a suite of new parsing/normalisation helpers; the compiler now promotes valid enums directly to type: 'domain' with a normalised ruleSpec, and EnumTestDataGenerator is retired in favour of routing all enum rules through DomainTestDataGenerator.
  • Validator wiring: command-help-validators.js delegates to normalizeDatatypeEnumValuesFromContext (new in datatype-enum.js) instead of maintaining its own extraction loop.
  • Test matrix cleanup: several large static JSON/markdown fixture files are deleted and replaced with smaller smoke suites wired against in-memory pages.

Confidence Score: 4/5

The refactoring is well-structured and extensively tested, but a regex mismatch between the new isCanonicalSchemaSerializableEnumRuleSpec guard and extractAwdEnumValues means any rule compiled from an empty-parens enum form (enum(), datatype.enum()) causes parseSchemaText to throw an uncaught exception at render time.

The empty-parentheses enum normalization path (isAwdEnumFormat permits [\s\S]* but extractAwdEnumValues requires .+) is an inconsistency introduced in this PR that can cause schema-conversion.cloneRule and renderSpecFromRulesWithTokens to throw rather than return an error object, breaking callers that expect either a valid result or a structured error.

packages/core/js/data_generation/utils/enumParser.js (the isAwdEnumFormat regex), packages/core/js/data_generation/schema-conversion.js (both normalization call sites), and packages/core/js/data_generation/rulesParser.js (the matching normalization call site).

Important Files Changed

Filename Overview
packages/core/js/data_generation/utils/enumParser.js Core enum parsing utility heavily expanded; isAwdEnumFormat allows empty parens ([\s\S]*) while extractAwdEnumValues requires non-empty content (.+), creating a normalization gate inconsistency that surfaces as an uncaught throw in schema-conversion
packages/core/js/data_generation/schema-conversion.js Added enum normalization in cloneRule and renderSpecFromRulesWithTokens; calls normalizeToCanonicalSchemaRuleSpec without try/catch after a guard that returns true for empty-parens enums, causing uncaught exceptions when such ruleSpecs reach this path
packages/core/js/data_generation/testDataRulesCompiler.js Invalid explicit enums now become type=domain with unchanged ruleSpec (e.g., enum() stays as enum()); this makes them fall into the schema-conversion normalization path which can then throw
packages/core/js/keywords/domain/datatype/datatype-enum.js New custom domain keyword executor for datatype.enum; normalizeDatatypeEnumValuesFromArgs multi-arg path returns raw (non-string) values unchanged, but this is safe in practice since validateEnumMemberValue stringifies before comparison
packages/core/js/data_generation/schema-rules-adapter.js Adds isDomainEnumCommand helper that canonicalizes datatype.enum / awd.datatype.enum rows to schema enum(...) form; does not handle the awd.domain.datatype.enum canonical alias (addressed in existing PR thread)
packages/core/js/domain/domain-keywords.js Refactored validateDomainKeywordArgs to support variadic args; registers datatype.enum custom delegate and adds comma-separated list type to isTypeMatch
packages/core/js/keywords/domain/datatype/enum-keyword-definition.js New DATATYPE_ENUM_KEYWORD_DEFINITION with variadic values arg, usage examples, and validateDatatypeEnumArgs semantic validator
packages/core/js/data_generation/rulesParser.js Both renderSpecFromRulesWithTokens render paths call normalizeToCanonicalSchemaRuleSpec without error handling; same empty-parens issue as schema-conversion affects this path too
packages/core/js/data_generation/rulesBasedDataGenerator.js Removed EnumTestDataGenerator in favour of routing all enum rules through DomainTestDataGenerator via inline ruleSpec normalization; normalizeToCanonicalDomainRuleSpec is still unguarded for the type==='enum' fallback path
packages/core/js/domain/domain-command-metadata.js New module that exposes sorted domain keyword entries and resolves docs URLs; straightforward utility with no issues

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Schema Text / Schema Rows"] --> B["TestDataRulesCompiler"]
    B --> C{"isEnumPattern?"}
    C -->|"Yes, valid"| D["type='domain'\nruleSpec=normalizeToCanonicalDomainRuleSpec"]
    C -->|"Yes, invalid explicit"| E["type='domain'\nruleSpec UNCHANGED\ne.g. enum()"]
    C -->|"No"| F["type='faker'/'literal'/'regex'/'domain'"]
    D --> G["RulesBasedDataGenerator\n→ DomainTestDataGenerator"]
    E --> H["schema-conversion.cloneRule"]
    H --> I{"isCanonicalSchemaSerializableEnumRuleSpec?"}
    I -->|"true for enum() via isAwdEnumFormat [\\s\\S]*"| J["normalizeToCanonicalSchemaRuleSpec\n→ extractAwdEnumValues (.+)\n⚠️ THROWS Invalid enum format"]
    I -->|"false"| K["ruleSpec passed through"]
    D --> L["schema-conversion.cloneRule\n→ normalizeToCanonicalSchemaRuleSpec ✓"]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["Schema Text / Schema Rows"] --> B["TestDataRulesCompiler"]
    B --> C{"isEnumPattern?"}
    C -->|"Yes, valid"| D["type='domain'\nruleSpec=normalizeToCanonicalDomainRuleSpec"]
    C -->|"Yes, invalid explicit"| E["type='domain'\nruleSpec UNCHANGED\ne.g. enum()"]
    C -->|"No"| F["type='faker'/'literal'/'regex'/'domain'"]
    D --> G["RulesBasedDataGenerator\n→ DomainTestDataGenerator"]
    E --> H["schema-conversion.cloneRule"]
    H --> I{"isCanonicalSchemaSerializableEnumRuleSpec?"}
    I -->|"true for enum() via isAwdEnumFormat [\\s\\S]*"| J["normalizeToCanonicalSchemaRuleSpec\n→ extractAwdEnumValues (.+)\n⚠️ THROWS Invalid enum format"]
    I -->|"false"| K["ruleSpec passed through"]
    D --> L["schema-conversion.cloneRule\n→ normalizeToCanonicalSchemaRuleSpec ✓"]
Loading

Reviews (13): Last reviewed commit: "Fix issue 228 accessibility and validati..." | Re-trigger Greptile

Comment thread packages/core-ui/js/gui_components/shared/test-data/schema/schema-runtime.js Outdated
Comment thread packages/core/js/keywords/domain/datatype/datatype-enum.js
Comment thread packages/core/js/data_generation/utils/enumParser.js
Comment thread packages/core/js/data_generation/schema-rules-adapter.js
Comment thread packages/core/js/data_generation/utils/enumParser.js Fixed
Comment thread packages/core/js/command-help/command-help-validators.js Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/js/data_generation/utils/enumParser.js`:
- Line 66: The regex in isCanonicalDomainEnumRuleSpec is vulnerable to
polynomial backtracking because the adjacent whitespace quantifiers overlap with
the broad payload match. Simplify the pattern by removing the redundant inner
\s* guards around the [\s\S]+ section so the expression still matches the same
enum rule specs but no longer creates ambiguous whitespace backtracking.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 24d39aa0-6935-4e9d-8cac-75f94cff24f0

📥 Commits

Reviewing files that changed from the base of the PR and between 8529bd7 and 363d2d6.

📒 Files selected for processing (8)
  • packages/core/js/data_generation/schema-rules-adapter.js
  • packages/core/js/data_generation/testDataRulesCompiler.js
  • packages/core/js/data_generation/utils/enumParser.js
  • packages/core/js/keywords/domain/datatype/datatype-enum.js
  • packages/core/src/tests/data_generation/enum-surface-parity.test.js
  • packages/core/src/tests/data_generation/schema-rules-adapter.test.js
  • packages/core/src/tests/data_generation/unit/domain/domainKeywords.test.js
  • packages/core/src/tests/data_generation/unit/enum/enumTestDataGenerator.test.js
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/core/js/keywords/domain/datatype/datatype-enum.js
  • packages/core/js/data_generation/testDataRulesCompiler.js
  • packages/core/js/data_generation/schema-rules-adapter.js
  • packages/core/src/tests/data_generation/enum-surface-parity.test.js

Comment thread packages/core/js/data_generation/utils/enumParser.js Outdated
Comment thread packages/core/js/data_generation/utils/enumParser.js
Comment thread packages/core/js/data_generation/utils/enumParser.js
Comment thread packages/core/js/data_generation/utils/enumParser.js Fixed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/core/js/data_generation/utils/enumParser.js (2)

338-340: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Align extraction with case-insensitive detection and remove the CodeQL regex shape.

Line 340 rejects DATATYPE.ENUM(...) even though hasAwdEnumInvocationPrefix accepts it. The same regex keeps the overlapping \s*(.+)\s* pattern flagged by CodeQL; capture the full argument body and trim after matching.

Suggested fix
-    const match = ruleSpec.match(/^(?:enum|datatype\.enum|awd\.datatype\.enum)\s*\(\s*(.+)\s*\)$/);
+    const match = ruleSpec.match(/^(?:enum|datatype\.enum|awd\.datatype\.enum)\s*\(([\s\S]+)\)$/i);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/js/data_generation/utils/enumParser.js` around lines 338 - 340,
Update extractAwdEnumValues in enumParser.js so it matches the same
case-insensitive prefixes accepted by hasAwdEnumInvocationPrefix, including
DATATYPE.ENUM and AWD.DATATYPE.ENUM forms. Replace the current enum matching
regex shape that uses overlapping \s*(.+)\s* with a safer capture of the full
argument body, then trim the captured value after matching before parsing the
enum entries.

Source: Linters/SAST tools


268-294: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve escaped characters in quoted enum values.

Line 268 strips quote delimiters during tokenization, so Lines 292-293 no longer recognize quoted tokens and never unescape \" or \\. Canonical values like datatype.enum("a\"b") round-trip as a\"b instead of a"b; unterminated quotes are also accepted.

Suggested fix
       if (char === '"' && (i === 0 || paramsStr[i - 1] !== '\\')) {
         // Toggle quote state for unescaped quotes
         inQuotes = !inQuotes;
+        currentValue += char;
       } else if (char === ',' && !inQuotes) {
         // Found separator outside quotes
         values.push(currentValue.trim());
         currentValue = '';
@@
     // Add final value
     values.push(currentValue.trim());
 
+    if (inQuotes) {
+      throw new Error('Invalid enum format: unterminated quoted value');
+    }
+
     if (values.length === 0 || values.every((value) => value.length === 0)) {
       throw new Error('No valid values found in enum');
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/js/data_generation/utils/enumParser.js` around lines 268 - 294,
The enum tokenization in enumParser.js is stripping quote delimiters too early,
so quoted values are no longer recognized later and escaped sequences are not
properly restored. Update the parsing flow around the enum value collection and
the final normalization in the return map so quoted tokens remain identifiable
until after parsing, then unescape quoted values via unescapeQuotedEnumValue
only for truly quoted entries. Also make the parser reject unterminated quoted
strings instead of accepting them as valid enum values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/js/data_generation/enum/enumTestDataRuleValidator.js`:
- Around line 14-22: The fallback in enumTestDataRuleValidator currently turns
every non-explicit parse failure from parseEnumRuleSpec into success via
EnumParser.extractEnumValues, which lets malformed legacy enum specs slip
through. Update the validator to remove that blanket recovery or restrict it to
a clearly identifiable legacy CSV form, and keep parseEnumRuleSpec as the source
of truth for accepted implicit enums. Make the change in
enumTestDataRuleValidator so TestDataRulesCompiler.compile only canonicalizes
truly valid enum inputs.

In `@packages/core/js/keywords/domain/datatype/datatype-enum.js`:
- Around line 73-76: The enum value derivation in `getCandidates` only handles
`datatype.enum`, so `awd.datatype.enum` contexts fall through and return no
candidates. Update the command check in this enum parsing logic to treat
`awd.datatype.enum` the same as `datatype.enum`, and make sure the existing
`EnumParser.extractEnumDisplayValue(params)` and `candidates.push(params)` paths
are applied for both command names.

In `@packages/core/src/tests/data_formats/gherkin-convertor.test.js`:
- Around line 229-241: The GherkinConvertor data-table test only covers truthy
non-string values, so it can miss regressions where falsy primitives are
serialized as empty cells; update the existing `converts non-string values and
escapes gherkin table separators` test in `GherkinConvertor.fromDataTable` to
also assert `false` and `0` are preserved and stringified in the output,
alongside the current pipe-escaping checks.

In `@packages/core/src/tests/data_formats/html-convertor.test.js`:
- Around line 61-73: The regression test in HtmlConvertor.fromDataTable only
covers truthy non-string values, so add explicit assertions for falsy primitives
like false and 0 in the GenericDataTable export path to ensure they are
preserved instead of being dropped by truthiness-based conversion. Update the
existing test case in html-convertor.test.js to include rows or cells that
exercise false and 0, and verify the output contains their stringified values
alongside the existing HtmlConvertor and GenericDataTable coverage.

In `@packages/core/src/tests/data_formats/markdown-convertor.test.js`:
- Around line 347-359: The MarkdownConvertor test only verifies truthy primitive
rendering, so it would miss regressions where falsy values are dropped before
stringification. Tighten the existing fromDataTable test in
markdown-convertor.test.js by adding assertions for falsy non-string values
handled by GenericDataTable rows, using the same MarkdownConvertor output to
confirm false and 0 are preserved as strings alongside the current pipe-escaping
checks.

---

Outside diff comments:
In `@packages/core/js/data_generation/utils/enumParser.js`:
- Around line 338-340: Update extractAwdEnumValues in enumParser.js so it
matches the same case-insensitive prefixes accepted by
hasAwdEnumInvocationPrefix, including DATATYPE.ENUM and AWD.DATATYPE.ENUM forms.
Replace the current enum matching regex shape that uses overlapping \s*(.+)\s*
with a safer capture of the full argument body, then trim the captured value
after matching before parsing the enum entries.
- Around line 268-294: The enum tokenization in enumParser.js is stripping quote
delimiters too early, so quoted values are no longer recognized later and
escaped sequences are not properly restored. Update the parsing flow around the
enum value collection and the final normalization in the return map so quoted
tokens remain identifiable until after parsing, then unescape quoted values via
unescapeQuotedEnumValue only for truly quoted entries. Also make the parser
reject unterminated quoted strings instead of accepting them as valid enum
values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b94c9a6b-d740-4d1a-aa1b-c5c23dec6103

📥 Commits

Reviewing files that changed from the base of the PR and between 3b9afc1 and 8382b9e.

📒 Files selected for processing (19)
  • packages/core-ui/js/gui_components/shared/schema-row-rule-mapper.js
  • packages/core-ui/js/gui_components/shared/test-data/schema/schema-runtime.js
  • packages/core-ui/src/tests/generator/schema-row-rule-mapper.test.js
  • packages/core/js/command-help/command-help-validators.js
  • packages/core/js/data_generation/enum/enumTestDataRuleValidator.js
  • packages/core/js/data_generation/schema-rules-adapter.js
  • packages/core/js/data_generation/testDataRulesCompiler.js
  • packages/core/js/data_generation/utils/enum-rule-detection.js
  • packages/core/js/data_generation/utils/enumParser.js
  • packages/core/js/keywords/domain/datatype/datatype-enum.js
  • packages/core/src/tests/data_formats/export-string-conversion-bug-fix.test.js
  • packages/core/src/tests/data_formats/gherkin-convertor.test.js
  • packages/core/src/tests/data_formats/html-convertor.test.js
  • packages/core/src/tests/data_formats/markdown-convertor.test.js
  • packages/core/src/tests/data_generation/enum-format-bug-fix.test.js
  • packages/core/src/tests/data_generation/enum-surface-parity.test.js
  • packages/core/src/tests/data_generation/enum-value-format-generation.test.js
  • packages/core/src/tests/data_generation/unit/enum/enumParser.test.js
  • packages/core/src/tests/data_generation/user-reported-bug-http-method.test.js
💤 Files with no reviewable changes (3)
  • packages/core/src/tests/data_formats/export-string-conversion-bug-fix.test.js
  • packages/core/src/tests/data_generation/user-reported-bug-http-method.test.js
  • packages/core/src/tests/data_generation/enum-format-bug-fix.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/js/data_generation/testDataRulesCompiler.js

Comment on lines +14 to +22
if (!parsed.ok && !parsed.explicit) {
parsed = {
ok: true,
values: EnumParser.extractEnumValues(ruleSpec),
explicit: false,
source: 'legacy-enum-type',
error: '',
};
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Don’t treat every non-explicit parse failure as a valid legacy enum.

Lines 14-22 currently convert any parseEnumRuleSpec() failure with explicit: false into success by re-running extractEnumValues(). Because TestDataRulesCompiler.compile() canonicalizes anything this validator accepts, malformed non-explicit specs can now be silently normalized into datatype.enum(...) instead of being rejected. parseEnumRuleSpec() already covers the supported implicit CSV forms, so this fallback needs to be removed or narrowed to a predicate that proves a real legacy surface.

Suggested fix
-      if (!parsed.ok && !parsed.explicit) {
-        parsed = {
-          ok: true,
-          values: EnumParser.extractEnumValues(ruleSpec),
-          explicit: false,
-          source: 'legacy-enum-type',
-          error: '',
-        };
-      }
-
       if (!parsed.ok) {
         this.validationError = parsed.error;
         return false;
       }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!parsed.ok && !parsed.explicit) {
parsed = {
ok: true,
values: EnumParser.extractEnumValues(ruleSpec),
explicit: false,
source: 'legacy-enum-type',
error: '',
};
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/js/data_generation/enum/enumTestDataRuleValidator.js` around
lines 14 - 22, The fallback in enumTestDataRuleValidator currently turns every
non-explicit parse failure from parseEnumRuleSpec into success via
EnumParser.extractEnumValues, which lets malformed legacy enum specs slip
through. Update the validator to remove that blanket recovery or restrict it to
a clearly identifiable legacy CSV form, and keep parseEnumRuleSpec as the source
of truth for accepted implicit enums. Make the change in
enumTestDataRuleValidator so TestDataRulesCompiler.compile only canonicalizes
truly valid enum inputs.

Comment on lines +73 to +76
if (command === 'datatype.enum' && params.length > 0) {
candidates.push(`datatype.enum(${EnumParser.extractEnumDisplayValue(params)})`);
candidates.push(params);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Handle awd.datatype.enum when deriving values from fieldDefinition.params.

Line 73 only recognizes datatype.enum, while the core-ui mapper now treats awd.datatype.enum as the same enum command. A context with fieldDefinition.command: 'awd.datatype.enum', params: 'active,inactive', and no ruleSpec falls through to [], causing valid enum-member validation to fail.

Proposed fix
-  if (command === 'datatype.enum' && params.length > 0) {
+  if ((command === 'datatype.enum' || command === 'awd.datatype.enum') && params.length > 0) {
     candidates.push(`datatype.enum(${EnumParser.extractEnumDisplayValue(params)})`);
     candidates.push(params);
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (command === 'datatype.enum' && params.length > 0) {
candidates.push(`datatype.enum(${EnumParser.extractEnumDisplayValue(params)})`);
candidates.push(params);
}
if ((command === 'datatype.enum' || command === 'awd.datatype.enum') && params.length > 0) {
candidates.push(`datatype.enum(${EnumParser.extractEnumDisplayValue(params)})`);
candidates.push(params);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/js/keywords/domain/datatype/datatype-enum.js` around lines 73 -
76, The enum value derivation in `getCandidates` only handles `datatype.enum`,
so `awd.datatype.enum` contexts fall through and return no candidates. Update
the command check in this enum parsing logic to treat `awd.datatype.enum` the
same as `datatype.enum`, and make sure the existing
`EnumParser.extractEnumDisplayValue(params)` and `candidates.push(params)` paths
are applied for both command names.

Comment on lines +229 to +241
test('converts non-string values and escapes gherkin table separators', () => {
let table = new GenericDataTable();
table.setHeaders(['Text', 'Number', 'Boolean']);
table.appendDataRow(['Data with | pipe', 42, true]);
table.appendDataRow(['plain data', 3.14, false]);

let output = new GherkinConvertor().fromDataTable(table);

expect(output).toContain('Data with \\| pipe');
expect(output).toContain('42');
expect(output).toContain('true');
assertNoCommonErrorPatternsInValue(output);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Pin the false/0 serialization path here as well.

Right now this verifies only truthy non-string values. That misses the common regression where falsy primitives are treated as empty cells before escaping/stringification.

Suggested test tightening
-      table.appendDataRow(['plain data', 3.14, false]);
+      table.appendDataRow(['plain data', 0, false]);
@@
       expect(output).toContain('42');
+      expect(output).toContain('0');
       expect(output).toContain('true');
+      expect(output).toContain('false');
       assertNoCommonErrorPatternsInValue(output);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('converts non-string values and escapes gherkin table separators', () => {
let table = new GenericDataTable();
table.setHeaders(['Text', 'Number', 'Boolean']);
table.appendDataRow(['Data with | pipe', 42, true]);
table.appendDataRow(['plain data', 3.14, false]);
let output = new GherkinConvertor().fromDataTable(table);
expect(output).toContain('Data with \\| pipe');
expect(output).toContain('42');
expect(output).toContain('true');
assertNoCommonErrorPatternsInValue(output);
});
test('converts non-string values and escapes gherkin table separators', () => {
let table = new GenericDataTable();
table.setHeaders(['Text', 'Number', 'Boolean']);
table.appendDataRow(['Data with | pipe', 42, true]);
table.appendDataRow(['plain data', 0, false]);
let output = new GherkinConvertor().fromDataTable(table);
expect(output).toContain('Data with \\| pipe');
expect(output).toContain('42');
expect(output).toContain('0');
expect(output).toContain('true');
expect(output).toContain('false');
assertNoCommonErrorPatternsInValue(output);
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/tests/data_formats/gherkin-convertor.test.js` around lines
229 - 241, The GherkinConvertor data-table test only covers truthy non-string
values, so it can miss regressions where falsy primitives are serialized as
empty cells; update the existing `converts non-string values and escapes gherkin
table separators` test in `GherkinConvertor.fromDataTable` to also assert
`false` and `0` are preserved and stringified in the output, alongside the
current pipe-escaping checks.

Comment on lines +61 to +73
test('converts non-string values and escapes html markup characters', () => {
let table = new GenericDataTable();
table.setHeaders(['Text', 'Number', 'Boolean']);
table.appendDataRow(['Data with < and >', 42, true]);
table.appendDataRow(['plain data', 3.14, false]);

let output = new HtmlConvertor().fromDataTable(table);

expect(output).toContain('Data with &lt; and &gt;');
expect(output).toContain('42');
expect(output).toContain('true');
assertNoCommonErrorPatternsInValue(output);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Cover the falsy primitive cases in this regression test.

Lines 69-72 only prove truthy non-strings survive export. A truthiness regression like value ? String(value) : '' would still pass here, even though false/0 are the values most likely to get dropped. packages/core/js/data_formats/generic-data-table.js already uses that pattern, so this edge case is worth pinning explicitly.

Suggested test tightening
-    table.appendDataRow(['plain data', 3.14, false]);
+    table.appendDataRow(['plain data', 0, false]);
@@
     expect(output).toContain('42');
+    expect(output).toContain('0');
     expect(output).toContain('true');
+    expect(output).toContain('false');
     assertNoCommonErrorPatternsInValue(output);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('converts non-string values and escapes html markup characters', () => {
let table = new GenericDataTable();
table.setHeaders(['Text', 'Number', 'Boolean']);
table.appendDataRow(['Data with < and >', 42, true]);
table.appendDataRow(['plain data', 3.14, false]);
let output = new HtmlConvertor().fromDataTable(table);
expect(output).toContain('Data with &lt; and &gt;');
expect(output).toContain('42');
expect(output).toContain('true');
assertNoCommonErrorPatternsInValue(output);
});
test('converts non-string values and escapes html markup characters', () => {
let table = new GenericDataTable();
table.setHeaders(['Text', 'Number', 'Boolean']);
table.appendDataRow(['Data with < and >', 42, true]);
table.appendDataRow(['plain data', 0, false]);
let output = new HtmlConvertor().fromDataTable(table);
expect(output).toContain('Data with &lt; and &gt;');
expect(output).toContain('42');
expect(output).toContain('0');
expect(output).toContain('true');
expect(output).toContain('false');
assertNoCommonErrorPatternsInValue(output);
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/tests/data_formats/html-convertor.test.js` around lines 61
- 73, The regression test in HtmlConvertor.fromDataTable only covers truthy
non-string values, so add explicit assertions for falsy primitives like false
and 0 in the GenericDataTable export path to ensure they are preserved instead
of being dropped by truthiness-based conversion. Update the existing test case
in html-convertor.test.js to include rows or cells that exercise false and 0,
and verify the output contains their stringified values alongside the existing
HtmlConvertor and GenericDataTable coverage.

Comment thread packages/core/src/tests/data_formats/markdown-convertor.test.js
Comment on lines +74 to +81
const executableRule =
rule.type === 'enum'
? {
...rule,
type: 'domain',
ruleSpec: EnumParser.normalizeToCanonicalDomainRuleSpec(rule.ruleSpec),
}
: rule;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Unguarded throw in runtime enum fallback

EnumParser.normalizeToCanonicalDomainRuleSpec calls extractEnumValues internally, which throws 'Invalid enum format' for malformed ruleSpecs. Because this construction happens before generator.generateFrom, any exception propagates directly to the caller rather than returning a graceful { isError: true } response object. The old EnumTestDataGenerator encapsulated this error path within its own generateFrom handler. A guard here preserves the error-response contract for callers that don't first gate on successful compilation/validation.

Suggested change
const executableRule =
rule.type === 'enum'
? {
...rule,
type: 'domain',
ruleSpec: EnumParser.normalizeToCanonicalDomainRuleSpec(rule.ruleSpec),
}
: rule;
let executableRule = rule;
if (rule.type === 'enum') {
try {
executableRule = {
...rule,
type: 'domain',
ruleSpec: EnumParser.normalizeToCanonicalDomainRuleSpec(rule.ruleSpec),
};
} catch {
value = dataResponse(rule.name, '**ERROR**', false, true);
break;
}
}

Comment on lines 32 to 34
static isAwdEnumFormat(ruleSpec) {
return /^(enum|datatype\.enum|awd\.datatype\.enum)\s*\(/.test(ruleSpec);
return /^(enum|datatype\.enum|awd\.datatype\.enum)\s*\([\s\S]*\)$/i.test(String(ruleSpec || '').trim());
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 isAwdEnumFormat allows empty parentheses via [\s\S]*, so isCanonicalSchemaSerializableEnumRuleSpec returns true for enum() and datatype.enum(). normalizeToCanonicalSchemaRuleSpec then calls extractAwdEnumValues, whose match regex uses (.+) (one-or-more), which fails for empty parens and throws 'Invalid enum format'. Because neither schema-conversion.cloneRule nor either renderSpecFromRulesWithTokens function wraps that call in a try/catch, any rule whose ruleSpec survived compilation as enum() or datatype.enum() causes parseSchemaText or renderSchemaText to throw an uncaught exception. Aligning isAwdEnumFormat to require at least one character closes the gap.

Suggested change
static isAwdEnumFormat(ruleSpec) {
return /^(enum|datatype\.enum|awd\.datatype\.enum)\s*\(/.test(ruleSpec);
return /^(enum|datatype\.enum|awd\.datatype\.enum)\s*\([\s\S]*\)$/i.test(String(ruleSpec || '').trim());
}
static isAwdEnumFormat(ruleSpec) {
return /^(enum|datatype\.enum|awd\.datatype\.enum)\s*\([\s\S]+\)$/i.test(String(ruleSpec || '').trim());
}

@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown

Too many files changed for review. (120 files found, 100 file limit)

*/
static extractAwdEnumValues(ruleSpec) {
// Match patterns like: enum(value1,value2) or enum("value1", "value2", "value3")
const match = ruleSpec.match(/^(?:enum|datatype\.enum|awd\.datatype\.enum)\s*\(\s*([\s\S]*)\s*\)$/);
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.

improve command definition

3 participants