Skip to content

fix: make warehouseId optional in ServiceContext when no plugin requires it#91

Open
pffigueiredo wants to merge 10 commits intomainfrom
fix-required-warehouseID
Open

fix: make warehouseId optional in ServiceContext when no plugin requires it#91
pffigueiredo wants to merge 10 commits intomainfrom
fix-required-warehouseID

Conversation

@pffigueiredo
Copy link

@pffigueiredo pffigueiredo commented Feb 9, 2026

Description

Makes warehouseId optional in ServiceContext when no registered plugin declares a SQL Warehouse in its manifest. Previously, ServiceContext.createContext() always called getWarehouseId(client), which in production throws if DATABRICKS_WAREHOUSE_ID is unset, and in dev triggers an unnecessary API call.

The need for a warehouse is now derived from the existing plugin manifest / ResourceRegistry: if any plugin declares a required sql_warehouse resource in its manifest, ServiceContext resolves the warehouse; otherwise it is skipped. No new plugin API (e.g. requiredResources) was added — the manifest is the single source of truth.

FEATURES

  • ServiceContext.initialize(options?, client?) accepts options?.warehouseId to gate warehouse resolution.
  • AppKit._createApp() uses ResourceRegistry: collect resources from manifests, derive needsWarehouse from registry.getRequired() (any ResourceType.SQL_WAREHOUSE), then call ServiceContext.initialize({ warehouseId: needsWarehouse }) before registry.enforceValidation().

FIXES

  • createApp({ plugins: [server()] }) no longer fails when DATABRICKS_WAREHOUSE_ID is missing.
  • Apps without warehouse-dependent plugins (e.g. analytics) avoid unnecessary warehouse ID resolution and API calls.

BREAKING CHANGES

  • None. Existing plugins that declare sql_warehouse in their manifest (e.g. Analytics) keep current behavior; apps using only server() no longer need the env var.

@pffigueiredo pffigueiredo requested review from MarioCadenas and pkosiec and removed request for MarioCadenas February 9, 2026 14:17
pffigueiredo and others added 5 commits February 9, 2026 14:23
Adds a `static requires` mechanism to the Plugin class so plugins can
declare which shared resources they need (e.g. warehouseId). At startup,
createApp() collects requirements from all plugins and passes them to
ServiceContext.initialize(), which only resolves warehouseId when a
plugin declared it. Apps using only server() no longer need
DATABRICKS_WAREHOUSE_ID set.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Pedro Figueiredo <klisarkk@gmail.com>
@pffigueiredo pffigueiredo force-pushed the fix-required-warehouseID branch from 7f4191c to f5e252d Compare February 9, 2026 14:25
@pffigueiredo pffigueiredo marked this pull request as draft February 9, 2026 14:32
@pffigueiredo
Copy link
Author

This is in Draft due to clash with other features that are being worked on right now.

@pkosiec pkosiec self-assigned this Feb 25, 2026

// Collect required resources from all plugins before initializing context
const rawPlugins = config.plugins as T;
const requiredResources = AppKit.collectRequiredResources(rawPlugins);
Copy link
Member

Choose a reason for hiding this comment

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

Could you please rebase your PR? There's resource registry now, where all Plugins have their manifests with required resources. Maybe we could use it to mark plugin as the one which needs the warehouse ID? 🤔

pffigueiredo and others added 4 commits February 25, 2026 16:55
Resolve conflicts keeping the branch's simplified requiredResources
approach over main's manifest/ResourceRegistry system.

Co-authored-by: Cursor <cursoragent@cursor.com>
@pffigueiredo pffigueiredo marked this pull request as ready for review February 25, 2026 17:47
@pffigueiredo pffigueiredo assigned pffigueiredo and unassigned pkosiec Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants