jobs plugin: named/multiple jobs crash-loop at startup (manifest hardcodes `DATABRICKS_JOB_ID`)

未關閉
#548 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 3 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
72/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
node.js, typescript
領域
tooling

研究方向

從 plugins/jobs/manifest.json 開始,將其所需資源與 plugins/jobs/plugin.ts:132 中的 JobsPlugin.getResourceRequirements() 進行比較。閱讀 registry/resource-registry.ts 中的 ResourceRegistry.collectResources,然後使用 createApp 重現具名 job 和預設 job;當具名 job 能夠在沒有 DATABRICKS_JOB_ID 的情況下啟動,且預設 job 仍然正常運作時,即表示完成。此外還要檢查 appkit 外掛程式同步,目前它只讀取靜態 manifest。

由索引模型根據 Issue 內容生成。

描述

Summary

When the jobs plugin is configured with a named job, the app fails to start: it reports DATABRICKS_JOB_ID as a missing required resource, even though only named jobs (e.g. DATABRICKS_JOB_ETL) were configured. A single unnamed job bound to DATABRICKS_JOB_ID starts as expected.

Version

@databricks/appkit v0.63.0 (git 62451912) · Databricks Apps (also reproduces locally via createApp).

Reproduction

import { createApp, jobs } from '@databricks/appkit';

createApp({ plugins: [jobs({ jobs: { etl: {} } })] });
// env: DATABRICKS_JOB_ETL=<id>   (DATABRICKS_JOB_ID unset)

Expected: the app boots with an etl job accessor.
Actual: startup fails with a missing-required-resources error naming DATABRICKS_JOB_ID.

Root cause

The jobs plugin declares its job resource twice, and the two disagree:

  • Static: plugins/jobs/manifest.json hardcodes DATABRICKS_JOB_ID as required (resourceKey: "job").
  • Dynamic: JobsPlugin.getResourceRequirements() (plugins/jobs/plugin.ts:132) emits DATABRICKS_JOB_<NAME> per job (job-<name>; the default key → DATABRICKS_JOB_ID).

ResourceRegistry.collectResources (registry/resource-registry.ts) registers both — the static required loop near line 106 and the dynamic loop near line 118. The mismatched keys (job vs job-<name>) never merge, so a named-jobs app is left with an unsatisfiable static DATABRICKS_JOB_ID requirement. The single-default case works only because its dynamic env is also DATABRICKS_JOB_ID.

serving and files share this static-plus-dynamic pattern but escape the crash by reusing the static env var; jobs can't, since named jobs derive DATABRICKS_JOB_<NAME>.

Separately, appkit plugin sync resolves only the static manifest.json (getResourceRequirements is unused in the CLI), so appkit.plugins.json is blind to named jobs too.

Suggested fix (via Claude)

Drop the hardcoded required job from plugins/jobs/manifest.json (resources.required: []) and let getResourceRequirements() be the single source of truth — it already maps default → DATABRICKS_JOB_ID, so the single-default case keeps working and named jobs stop demanding a phantom DATABRICKS_JOB_ID.

主要語言
TypeScript
星號
119
分支
36
平均合併
4 天 16 小時
30 天內合併 PR
37

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

databricks/appkit 的其他 Issue

查看 databricks/appkit 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。