Skip to content

Serverless products should not allow versioning#2920

Open
cotti wants to merge 3 commits intomainfrom
fix/applies-to-versioning-for-versionless
Open

Serverless products should not allow versioning#2920
cotti wants to merge 3 commits intomainfrom
fix/applies-to-versioning-for-versionless

Conversation

@cotti
Copy link
Contributor

@cotti cotti commented Mar 18, 2026

Fixes #2627

This pull request introduces stricter validation for version specifications in "versionless" products (such as ess, ech, serverless, elasticsearch, observability, and security) 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:

  • Added a validation step in ApplicableToYamlConverter.cs to 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:

  • Updated all relevant tests to remove versions from versionless product applicability (e.g., serverless: ga 9.0.0serverless: 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]
  • Added new tests to explicitly verify that specifying a version for a versionless product emits the appropriate error message. [1] [2]

These changes ensure that the applicability logic is more robust and that documentation authors receive clear feedback when misusing versioned declarations for versionless products.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ApplicableToYamlConverter to 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. "));
Comment on lines +286 to +290
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. "));
Comment on lines +87 to +107
[<Fact>]
let ``emits error because ess does not support versions`` () =
markdown |> hasError "Can't specify a version for 'ess'"

Comment on lines +487 to +494
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'"
@github-actions
Copy link

🔍 Preview links for changed docs

@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 45b236c3-df9d-416c-a9bf-dbb942908887

📥 Commits

Reviewing files that changed from the base of the PR and between eddabfa and b97503a.

📒 Files selected for processing (5)
  • docs/syntax/applies.md
  • src/Elastic.Documentation/AppliesTo/ApplicableToYamlConverter.cs
  • tests/authoring/Applicability/AppliesToDirective.fs
  • tests/authoring/Applicability/AppliesToFrontMatter.fs
  • tests/authoring/Inline/AppliesToRole.fs

📝 Walkthrough

Walkthrough

The changes implement validation to prevent version specifications on versionless product keys. Documentation examples were updated to remove version suffixes from serverless, ess, ech, elasticsearch, observability, and security lifecycle states. Code validation now enforces that these keys cannot include explicit versions—if they do, a diagnostic error is generated. Test fixtures and expected values were updated to reflect versionless states, and new error-case tests were added to verify that versioned input for versionless keys produces appropriate errors.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed PR fully implements issue #2627 requirements: validates that versionless keys (serverless, ech, elasticsearch, observability, security, ess) reject version specifications with appropriate error diagnostics.
Out of Scope Changes check ✅ Passed All changes align with the versioning restriction objective; documentation and tests are updated consistently to reflect the new validation rules without introducing unrelated modifications.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/applies-to-versioning-for-versionless
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Applies_to: Forbid versions for non-versioned products

2 participants