Repository navigation
feat: introduce v3 schema with Go template support - #67
Conversation
Add RequestTemplate type and file-level template field to FTWTest,
allowing tests to define the HTTP request structure once and inject
per-test payloads via {{.Payload}} in URI, data, and header values.
Tests can now use the simplified format (id + description + payload +
output) instead of explicit stages. Stages remain fully supported for
multi-step and complex tests, preserving backward compatibility.
Other v3 additions:
- `id` and `description` as YAML aliases for `test_id` and `desc`
- test-level `output` field for payload-based tests
- module path bumped to github.com/coreruleset/ftw-tests-schema/v3
- spec/v3.0.0 JSON schemas generated
- README updated with v3 and v2 format examples and version history
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 43 minutes and 45 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe Go module is promoted from v2 to v3. The core type file adds a file-level Changesftw-tests-schema v3 upgrade
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 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 `@README.md`:
- Around line 187-189: The fenced code blocks in the README.md file are missing
language identifiers, which triggers markdown linting issues and reduces
consistency. Add the bash language identifier to the two code fences: the first
one containing the go install command for yamldoc-go at lines 187-189, and the
second one containing the mkdir and mage commands at lines 205-208. Change each
opening fence from triple backticks to triple backticks followed by bash.
In `@spec/v3.0.0/waf-platform-overrides-schema-v3.0.0.json`:
- Line 1: The annotations property in the FTWOverridesMeta definition is
declared as an array type but uses additionalProperties instead of items to
define element validation, leaving item types unconstrained. Replace the
additionalProperties constraint with an items property that specifies type
string to properly enforce that each array element is a string.
In `@spec/v3.0.0/waf-tests-schema-v3.0.0.json`:
- Line 1: The HeaderTuple definition in the schema has property names cased as
Name and Value with additionalProperties set to false, but the v3 examples and
tests use lowercase name and value. Change the properties in the HeaderTuple
object definition to use lowercase name and value instead of Name and Value, and
update the required array to reflect these lowercase property names to match the
actual usage in v3 examples and tests.
- Line 1: The Test object definition in the schema only accepts test_id and desc
properties with additionalProperties set to false, which rejects the documented
v3 aliases id and description supported by the UnmarshalYAML implementation in
types.go. Add id and description as valid optional properties in the Test
definition with the same type constraints as test_id and desc respectively, so
that valid tests using the shorthand aliases will pass schema validation.
- Line 1: The Test schema definition is currently missing validation rules to
enforce the mutually exclusive payload-mode versus stages-mode contract. The
Test object should require either the payload and output properties together, or
the stages property alone, but not allow arbitrary combinations of these. Add a
oneOf constraint in the Test definition that enforces two distinct schemas: one
for payload-mode tests that requires test_id and payload with output, and
another for stages-mode tests that requires test_id with stages. This will
prevent invalid test definitions where both payload and stages are specified
together, or where output is used without payload.
🪄 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: e8a6ab51-d862-435d-8aef-e808503223f4
📒 Files selected for processing (11)
README.mdcmd/generate-doc-yaml-schema/main.gogo.modmagefile.gospec/v3.0.0/waf-platform-overrides-schema-v3.0.0.jsonspec/v3.0.0/waf-tests-schema-v3.0.0.jsontypes/examples.gotypes/overrides/examples.gotypes/overrides/types.gotypes/types.gotypes/types_test.go
Fix dstdocgen crash (Go 1.22 binary vs Go 1.25 module): reinstalled with current toolchain. Root cause in types.go: double-quoted values inside description strings (e.g. "http" or "https") were embedded unescaped into the LineComment field of generated code, producing a Go syntax error. Removed inline double quotes from Protocol, Version, and Method descriptions in RequestTemplate. Address CodeRabbit findings: - README: add bash language identifier to two fenced code blocks - HeaderTuple: add yaml/json tags (name, value) so schema and YAML parsing use lowercase keys, matching actual test file usage - Test schema: expose id and description as valid optional properties (v3 aliases for test_id and desc) via IdAlias/DescriptionAlias fields with yaml:"-"; make test_id omitempty so neither alias is required - Regenerate spec/v3.0.0 JSON schemas Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The Annotations field is map[string]string, which should generate a
JSON Schema object with additionalProperties. The jsonschema:"type=array"
tag was incorrect: it forced type=array but left additionalProperties
(an object keyword) as the item validator, making item types
unconstrained and the schema internally inconsistent.
Removing the tag produces {type: object, additionalProperties: {type: string}},
which correctly matches both the Go type and the YAML key-value usage.
Regenerate spec/v3.0.0/waf-platform-overrides-schema-v3.0.0.json.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@coderabbitui full_review |
Co-authored-by: Max Leske <250711+theseion@users.noreply.github.com>
In v3, `id` and `description` are now the primary YAML/JSON field names. The v2 names `test_id` and `desc` are still accepted via UnmarshalYAML but are deprecated aliases. Also simplifies UnmarshalYAML to use a `type rawTest Test` alias instead of an explicit parallel struct. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
RequestTemplatetype and a file-leveltemplatefield toFTWTest, so tests can define the HTTP request structure once and inject per-test payloads via{{.Payload}}in URI, data, and header valuesid+description+payload+output) instead of explicit stages; thestagesformat remains fully supported for multi-step testsgithub.com/coreruleset/ftw-tests-schema/v3Changes
RequestTemplatestruct with template-capableuri,data, and header valuesFTWTest.Template— file-level default request templateTest.Payload,Test.Template,Test.Output— simplified per-test fieldsUnmarshalYAMLonTestacceptsid/descriptionas aliases fortest_id/descspec/v3.0.0/— generated JSON schemas for tests and platform overridesBackward compatibility
All v2 test files parse and behave identically. Deprecated fields (
stop_magic,log_contains,no_log_contains,headersmap,enabled,test_title) are preserved in structs so existing test files produce correct results without modification.Test plan
go test ./...passes (all 6 tests green)mage jsonSchemasregeneratesspec/v3.0.0/correctlytypes/types_test.gostill unmarshals correctly (TestUnmarshalFTWTest)id/descriptionaliases (TestUnmarshalV3Format)🤖 Generated with Claude Code
Summary by CodeRabbit
id,description) with backward-compatible parsing.