Skip to content

Serverless products should not allow versioning#2920

Merged
cotti merged 4 commits intomainfrom
fix/applies-to-versioning-for-versionless
Apr 16, 2026
Merged

Serverless products should not allow versioning#2920
cotti merged 4 commits intomainfrom
fix/applies-to-versioning-for-versionless

Conversation

@cotti
Copy link
Copy Markdown
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.

@cotti cotti self-assigned this Mar 18, 2026
@cotti cotti added the fix label Mar 18, 2026
@cotti cotti requested a review from a team as a code owner March 18, 2026 23:41
@cotti cotti requested review from Copilot and technige March 18, 2026 23:41
Copy link
Copy Markdown
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.

Comment thread src/Elastic.Documentation/AppliesTo/ApplicableToYamlConverter.cs Outdated
Comment thread src/Elastic.Documentation/AppliesTo/ApplicableToYamlConverter.cs Outdated
Comment thread tests/authoring/Applicability/AppliesToFrontMatter.fs Outdated
Comment thread tests/authoring/Applicability/AppliesToFrontMatter.fs
@cotti cotti requested a review from a team as a code owner March 19, 2026 12:33
@github-actions
Copy link
Copy Markdown

🔍 Preview links for changed docs

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: dc471018-75b1-4cbd-95ef-cdae2bbc591e

📥 Commits

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

📒 Files selected for processing (1)
  • src/Elastic.Documentation/AppliesTo/ApplicableToYamlConverter.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Elastic.Documentation/AppliesTo/ApplicableToYamlConverter.cs

📝 Walkthrough

Walkthrough

The changes add validation that forbids specifying explicit versions for versionless product keys (e.g., serverless, ess, ech, elasticsearch, observability, security). The YAML parser/processor was updated to invoke ValidateApplicabilityCollection for parsed applicability collections and to emit an error diagnostic if any item includes a version for those versionless keys. Documentation examples and tests were updated to remove version suffixes and new tests assert error behavior when versions are provided for versionless fields.

Sequence Diagram(s)

sequenceDiagram
    participant Author as Author (YAML)
    participant Parser as AppliesToYamlConverter
    participant Validator as ValidateApplicabilityCollection
    participant Diag as Diagnostics
    participant Builder as DeploymentApplicability Builder
    Author->>Parser: Provide applies_to YAML (e.g., serverless: "ga 9.0")
    Parser->>Parser: Parse applicability items -> AppliesCollection
    Parser->>Validator: ValidateApplicabilityCollection(key, applies, diagnostics)
    Validator->>Validator: Check VersionlessKeys for any versioned item
    alt version found for versionless key
        Validator->>Diag: Add Error diagnostic ("Can't specify a version for ...")
        Validator-->>Parser: Return early (skip further rules)
        Parser-->>Diag: Propagate error result
    else no version found
        Validator-->>Parser: Continue validation
        Parser->>Builder: Construct DeploymentApplicability using applies
        Builder-->>Parser: Return applicability object
    end
    Note right of Diag: Tests assert diagnostics or constructed object accordingly
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: preventing version specifications for versionless products in applicability parsing.
Description check ✅ Passed The description clearly explains the validation enhancements, test updates, and rationale aligned with the changeset modifications.
Linked Issues check ✅ Passed The PR fully addresses issue #2627 by enforcing version restrictions for versionless products (ess, ech, serverless, etc.) and emitting appropriate diagnostic errors.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the versionless product validation requirement. No unrelated modifications were introduced.

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

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/applies-to-versioning-for-versionless

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

@cotti cotti merged commit 5f38153 into main Apr 16, 2026
66 of 78 checks passed
@cotti cotti deleted the fix/applies-to-versioning-for-versionless branch April 16, 2026 17:52
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

3 participants