Conversation
There was a problem hiding this comment.
Pull request overview
Adds stricter validation to the applies_to YAML parsing so that “versionless” products/projects (e.g., ess, ech, serverless, and serverless sub-projects) cannot include a version, and updates tests to reflect this behavior.
Changes:
- Added versionless-key validation in
ApplicableToYamlConverterto emit errors when a version is specified for versionless keys. - Updated existing applicability tests to remove versions from versionless keys.
- Added new tests asserting that versioned declarations for versionless keys emit errors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/Elastic.Documentation/AppliesTo/ApplicableToYamlConverter.cs |
Adds versionless-key detection and emits diagnostics errors when versions are used for those keys. |
tests/authoring/Inline/AppliesToRole.fs |
Updates inline {applies_to} role tests to remove versions from ess / ech. |
tests/authoring/Applicability/AppliesToFrontMatter.fs |
Updates frontmatter tests to remove versions for versionless keys and adds explicit error tests for versioned usage. |
tests/authoring/Applicability/AppliesToDirective.fs |
Updates directive-based YAML tests to remove versions from serverless sub-projects. |
| { | ||
| if (items.Any(a => a.Version is not null && a.Version != AllVersionsSpec.Instance)) | ||
| diagnostics.Add((Severity.Error, | ||
| $"Can't specify a version for '{key}' because this product is not versioned. ")); |
| if (VersionlessKeys.Contains(key)) | ||
| { | ||
| if (items.Any(a => a.Version is not null && a.Version != AllVersionsSpec.Instance)) | ||
| diagnostics.Add((Severity.Error, | ||
| $"Can't specify a version for '{key}' because this product is not versioned. ")); |
| [<Fact>] | ||
| let ``emits error because ess does not support versions`` () = | ||
| markdown |> hasError "Can't specify a version for 'ess'" | ||
|
|
| type ``deployment string shorthand with version emits error for ess`` () = | ||
| static let markdown = frontMatter """ | ||
| applies_to: | ||
| deployment: ga 9.0.0 | ||
| """ | ||
| [<Fact>] | ||
| let ``emits error because ess does not support versions`` () = | ||
| markdown |> hasError "Can't specify a version for 'ess'" |
🔍 Preview links for changed docs |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe changes implement validation to prevent version specifications on versionless product keys. Documentation examples were updated to remove version suffixes from 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip CodeRabbit can scan for known vulnerabilities in your dependencies using OSV Scanner.OSV Scanner will automatically detect and report security vulnerabilities in your project's dependencies. No additional configuration is required. |
Fixes #2627
This pull request introduces stricter validation for version specifications in "versionless" products (such as
ess,ech,serverless,elasticsearch,observability, andsecurity) within the applicability YAML parsing logic. It ensures that these products cannot be assigned a version, and emits clear errors if a version is mistakenly specified. The changes also update the test suite to reflect and verify this new validation behavior.Validation and Parsing Enhancements:
ApplicableToYamlConverter.csto prevent specifying versions for versionless products (ess,ech,serverless,elasticsearch,observability,security). If a version is provided for these, an error is added to diagnostics. [1] [2] [3] [4]Test Suite Updates:
serverless: ga 9.0.0→serverless: ga) and to expect errors when a version is specified for such products. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]These changes ensure that the applicability logic is more robust and that documentation authors receive clear feedback when misusing versioned declarations for versionless products.