forked from zereight/gitlab-mcp
-
Notifications
You must be signed in to change notification settings - Fork 1
feat(availability): use WidgetAvailability for version-based widget validation #137
Copy link
Copy link
Closed
Description
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.tshas version requirements per widget (e.g.,CUSTOM_FIELDS: { minVersion: 17.0 })GitLabVersionDetector.tsalready 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_RESTRICTEDstructured error (extenderror-handler.ts) - Keep
WidgetAvailability.tsas the source of truth for version requirements
Relationship to Other Issues
- feat(workitems): extend manage_work_item with date, time tracking, and tier-specific widgets #135 — adds the widget parameters
- feat(availability): extend tier matrix with per-parameter gating #136 — gates parameters by TIER at schema level (build time)
- This issue — gates parameters by VERSION at runtime (before API call)
Together: schema shows only tier-appropriate params, runtime validates version compatibility.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels