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 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
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 摘要。