Add experimental lifecycle to applies-to#3398
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR adds support for a new Possibly related issues
🚥 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✨ Simplify code
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/Elastic.Documentation/AppliesTo/ApplicableToJsonConverter.cs (1)
223-236:⚠️ Potential issue | 🟠 Major | ⚡ Quick winDo not default unknown JSON lifecycle values to GA.
Line 235 and Line 259 both coerce unknown lifecycle values to GA. This masks invalid input and can broaden applicability incorrectly. Fail fast with
JsonExceptioninstead.🔧 Proposed fix
private static ProductLifecycle ParseLifecycle(string lifecycleStr) => lifecycleStr.ToLowerInvariant() switch { "preview" => ProductLifecycle.TechnicalPreview, "experimental" => ProductLifecycle.Experimental, "beta" => ProductLifecycle.Beta, "ga" => ProductLifecycle.GenerallyAvailable, "deprecated" => ProductLifecycle.Deprecated, "removed" => ProductLifecycle.Removed, "unavailable" => ProductLifecycle.Unavailable, "development" => ProductLifecycle.Development, "planned" => ProductLifecycle.Planned, "discontinued" => ProductLifecycle.Discontinued, - _ => ProductLifecycle.GenerallyAvailable + _ => throw new JsonException($"Unknown lifecycle '{lifecycleStr}'.") }; @@ var lifecycleName = applicability.Lifecycle switch { ProductLifecycle.TechnicalPreview => "preview", ProductLifecycle.Experimental => "experimental", ProductLifecycle.Beta => "beta", ProductLifecycle.GenerallyAvailable => "ga", ProductLifecycle.Deprecated => "deprecated", ProductLifecycle.Removed => "removed", ProductLifecycle.Unavailable => "unavailable", ProductLifecycle.Development => "development", ProductLifecycle.Planned => "planned", ProductLifecycle.Discontinued => "discontinued", - _ => "ga" + _ => throw new JsonException($"Unknown lifecycle '{applicability.Lifecycle}'.") };Also applies to: 247-260
🤖 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 `@src/Elastic.Documentation/AppliesTo/ApplicableToJsonConverter.cs` around lines 223 - 236, The ParseLifecycle method (and the other switch handling lifecycle values) currently maps unknown strings to ProductLifecycle.GenerallyAvailable; change the fallback behavior to throw a JsonException instead to fail-fast on invalid JSON input. Update the default arm of ParseLifecycle (and the analogous switch in the other lifecycle parsing method) to throw a JsonException with a clear message that includes the unrecognized lifecycleStr so callers can surface invalid input rather than silently coercing to GA.src/Elastic.Documentation/AppliesTo/ApplicableTo.cs (1)
134-147:⚠️ Potential issue | 🟠 Major | ⚡ Quick winFail fast instead of coercing unknown lifecycle to
ga.Line 146 silently maps unexpected enum values to
"ga", which can corrupt applies-to wire output. Throw here to surface bad state immediately.🔧 Proposed fix
private static string LifecycleName(ProductLifecycle lc) => lc switch { ProductLifecycle.TechnicalPreview => "preview", ProductLifecycle.Experimental => "experimental", ProductLifecycle.Beta => "beta", ProductLifecycle.GenerallyAvailable => "ga", ProductLifecycle.Deprecated => "deprecated", ProductLifecycle.Removed => "removed", ProductLifecycle.Unavailable => "unavailable", ProductLifecycle.Development => "development", ProductLifecycle.Planned => "planned", ProductLifecycle.Discontinued => "discontinued", - _ => "ga" + _ => throw new ArgumentOutOfRangeException(nameof(lc), lc, "Unknown product lifecycle.") };🤖 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 `@src/Elastic.Documentation/AppliesTo/ApplicableTo.cs` around lines 134 - 147, The switch expression in LifecycleName(ProductLifecycle lc) currently falls back to "ga" for unknown enum values and should instead fail fast; replace the wildcard arm (_ => "ga") with code that throws an ArgumentOutOfRangeException (or similar) including the invalid lc value and the parameter name, so any unexpected ProductLifecycle value surfaces immediately in LifecycleName.
🤖 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.
Outside diff comments:
In `@src/Elastic.Documentation/AppliesTo/ApplicableTo.cs`:
- Around line 134-147: The switch expression in LifecycleName(ProductLifecycle
lc) currently falls back to "ga" for unknown enum values and should instead fail
fast; replace the wildcard arm (_ => "ga") with code that throws an
ArgumentOutOfRangeException (or similar) including the invalid lc value and the
parameter name, so any unexpected ProductLifecycle value surfaces immediately in
LifecycleName.
In `@src/Elastic.Documentation/AppliesTo/ApplicableToJsonConverter.cs`:
- Around line 223-236: The ParseLifecycle method (and the other switch handling
lifecycle values) currently maps unknown strings to
ProductLifecycle.GenerallyAvailable; change the fallback behavior to throw a
JsonException instead to fail-fast on invalid JSON input. Update the default arm
of ParseLifecycle (and the analogous switch in the other lifecycle parsing
method) to throw a JsonException with a clear message that includes the
unrecognized lifecycleStr so callers can surface invalid input rather than
silently coercing to GA.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 0cdc053e-33c2-4a31-9222-92768ed45f91
📒 Files selected for processing (15)
docs/_snippets/applies_to-lifecycle.mddocs/syntax/applies-switch.mddocs/syntax/applies.mdsrc/Elastic.Documentation/AppliesTo/Applicability.cssrc/Elastic.Documentation/AppliesTo/ApplicableTo.cssrc/Elastic.Documentation/AppliesTo/ApplicableToJsonConverter.cssrc/Elastic.Documentation/AppliesTo/ProductLifecycle.cssrc/Elastic.Documentation/AppliesTo/ProductLifecycleInfo.cssrc/Elastic.Markdown/Myst/Components/ApplicabilityRenderer.cssrc/Elastic.Markdown/Myst/Components/LifecycleDescriptions.cstests/Elastic.Markdown.Tests/AppliesTo/ApplicabilityTryParseTests.cstests/Elastic.Markdown.Tests/AppliesTo/ApplicableToJsonConverterRoundTripTests.cstests/Elastic.Markdown.Tests/AppliesTo/ApplicableToJsonConverterSerializationTests.cstests/Elastic.Markdown.Tests/AppliesTo/ProductLifecycleInfoTests.cstests/authoring/Applicability/ApplicableToComponent.fs
Relates to #3310
This PR adds the
experimentallifecycle value for use in the "applies-to" docs feature.Generative AI disclosure
Tool(s) and model(s) used: composer-2
AI summary
Core parsing & serialization
ProductLifecycle.cs—Experimentalenum member with JSON nameexperimentalApplicability.cs— parse, serialize, and error-message supportApplicableToJsonConverter.cs— JSON read/writeApplicableTo.cs—LifecycleNamehelperRendering & metadata
ProductLifecycleInfo.cs—Experimentalat order 3; bumped Planned→Discontinued orders by 1LifecycleDescriptions.cs— placeholder popover text (released + unreleased)ApplicabilityRenderer.cs—BuildBadgeLifecycleText→"Planned"for unreleased experimentalDocumentation
docs/_snippets/applies_to-lifecycle.md— lifecycle listdocs/syntax/applies.md— Experimental rows in badge/popover tables, inline examples, validation ruledocs/syntax/applies-switch.md— experimentalapplies-itemin basic usage exampleTests
ApplicabilityTryParseTests.csApplicableToJsonConverterSerializationTests.csApplicableToJsonConverterRoundTripTests.cs—DeserializeExperimentalLifecycleProductLifecycleInfoTests.cs(new)ApplicableToComponent.fs— parse + HTML snapshot forstack: experimental 9.1.0