Skip to content

feat(availability): use WidgetAvailability for version-based widget validation #137

@polaz

Description

@polaz

Problem

WidgetAvailability.ts already defines minVersion for each widget, but this data is not used anywhere. When a user on an older GitLab instance (e.g., 15.x) tries to use a widget that requires 17.0+, they get a raw API error instead of a clear message.

Current State

  • WidgetAvailability.ts has version requirements per widget (e.g., CUSTOM_FIELDS: { minVersion: 17.0 })
  • GitLabVersionDetector.ts already detects instance version
  • Neither is connected to the work items handler

Target State

Use WidgetAvailability.isWidgetAvailable() at runtime in manage_work_item handler to validate that the requested widget parameters are supported by the target GitLab instance version.

Validation Flow

User requests manage_work_item with weight parameter
  → Map parameter to widget type (weight → WEIGHT)
  → Check WidgetAvailability.isWidgetAvailable("WEIGHT")
    → Check minVersion against detected instance version
    → Check tier (handled by #136 at schema level, but double-check here)
  → If unavailable: return structured error with required version + upgrade hint
  → If available: proceed with API call

Error Response

{
  "error": "Widget 'CUSTOM_FIELDS' requires GitLab >= 17.0 (detected: 16.5.0)",
  "widget": "CUSTOM_FIELDS",
  "required_version": "17.0",
  "detected_version": "16.5.0",
  "docs_url": "https://docs.gitlab.com/..."
}

Implementation

  • Add parameter-to-widget mapping in handler or schema definition
  • Call WidgetAvailability.isWidgetAvailable(widgetType) before constructing GraphQL input
  • Return VERSION_RESTRICTED structured error (extend error-handler.ts)
  • Keep WidgetAvailability.ts as the source of truth for version requirements

Relationship to Other Issues

Together: schema shows only tier-appropriate params, runtime validates version compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions