P2-6 修复: form/release precheck (P2-6, 2026-07-02)
FINDING-S2: form/release.ts 不走完整 precheck - 仅 import loadContextSafe (供 guards 用), 没用 preCheckFormRelease - 中途 enCode 已被别人占用仍能 release, 后端才报冲突 - 物理表 schema 缺失不预检 → release 失败原因不明 修复: - _precheck.ts 新加 preCheckFormRelease (enCode 在列表 + table 存在) - 跟 form/create preCheckFormCreate 对齐 - 用 soft warning (release 是发布现有 form, 跟 create 不同, 不硬阻断) - form/release.ts: 入口加 preCheckFormRelease 校验 - 从 guardCtx.releasedForms/unreleasedForms 推 enCode - 输出 warning 不阻断 (跟 form/create 一样, release 失败由后端真值报) 审计: dacli/docs/cmd-review/v0.14-rollout-audit-2026-07-02.md §5.1 S2
This commit is contained in:
1 parent
50e170cae0
commit
0c928e65ea
2 files changed
+52
-1
No files matched your search
@@ -174,6 +174,45 @@ export async function preCheckDmCreate(
|
||||
return { pass: errors.length === 0, errors, warnings }
|
||||
}
|
||||
|
||||
/**
|
||||
* form release pre-check (v0.15+, P2-6)
|
||||
*
|
||||
* 检查项:
|
||||
* 1. enCode 不重复 (同 create 校验, 防止 release 期间 enCode 已被别人占用)
|
||||
* 2. 物理表存在 (release 走 Actions/Release 端点, 后端可能校验 table schema)
|
||||
*
|
||||
* 注: 旧版 form/release.ts 不走 precheck → release 期间 enCode 已被别人占用仍能发
|
||||
* 修复: 加 preCheckFormRelease 入口校验, 跟 form/create 一致
|
||||
*/
|
||||
export async function preCheckFormRelease(
|
||||
_client: JnpfClient | null,
|
||||
opts: { enCode?: string; table?: string },
|
||||
): Promise<PreCheckResult> {
|
||||
const errors: string[] = []
|
||||
const warnings: string[] = []
|
||||
|
||||
const { ctx, warning } = await loadContextSafe(_client)
|
||||
if (warning) warnings.push(warning)
|
||||
|
||||
if (!ctx) {
|
||||
warnings.push('AppContext 加载失败,跳过 pre-check')
|
||||
return { pass: true, errors, warnings }
|
||||
}
|
||||
|
||||
// 检查 1: enCode 不重复 (除自己外, release 期间可能被改名)
|
||||
if (opts.enCode && !ctx.existingEnCodes.includes(opts.enCode)) {
|
||||
warnings.push(`enCode "${opts.enCode}" 在现有列表中未找到, 确认是当前 app 的 enCode?`)
|
||||
}
|
||||
|
||||
// 检查 2: 物理表 schema 存在
|
||||
if (opts.table && !ctx.existingTables.includes(opts.table)) {
|
||||
warnings.push(`物理表 "${opts.table}" 不在现有表列表中, 后端 release 可能失败`)
|
||||
warnings.push(' 修复: 先 dacli dm create 建表, 或确认表名拼写正确')
|
||||
}
|
||||
|
||||
return { pass: errors.length === 0, errors, warnings }
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印 pre-check 结果 (form/dm 共享)
|
||||
*
|
||||
|
||||
@@ -14,7 +14,7 @@ import { Command } from 'commander'
|
||||
import { JnpfClient } from '../../core/client.ts'
|
||||
import { installAiHelpHook } from '../../core/help.ts'
|
||||
import { log } from '../../core/log.ts'
|
||||
import { loadContextSafe } from '../_precheck.ts'
|
||||
import { loadContextSafe, preCheckFormRelease } from '../_precheck.ts'
|
||||
import { runGuards, handleGuardResult, formatIssues } from '../_blindspot_guards.ts'
|
||||
import { initWebapi, loadVisualDev } from '../../webapi/visualDev.ts'
|
||||
import { enhanceFromBackend, formatErrorLine } from '../_error_codes.ts'
|
||||
@@ -36,6 +36,18 @@ export function buildFormReleaseCommand(): Command {
|
||||
if (guardCtx.warning) log.warn(guardCtx.warning)
|
||||
handleGuardResult('form release', runGuards(guardCtx.ctx, { formId: id }, 'form release'))
|
||||
|
||||
// v0.15+ (P2-6): preCheckFormRelease (enCode 在当前 app 列表 + table 存在)
|
||||
// 旧版 release 不走 precheck, 中途 enCode 已被别人占用能过
|
||||
// 这里从 guardCtx.releasedForms/unreleasedForms 推 enCode
|
||||
const enCode = guardCtx.ctx?.releasedForms
|
||||
?.find(f => f.startsWith(`${id}:`))?.split(':')[1]
|
||||
?? guardCtx.ctx?.unreleasedForms
|
||||
?.find(f => f.startsWith(`${id}:`))?.split(':')[1]
|
||||
if (enCode && enCode !== '(no-enCode)') {
|
||||
const pre = await preCheckFormRelease(null, { enCode, table: '' })
|
||||
for (const w of pre.warnings) log.warn(` preCheckFormRelease: ${w}`)
|
||||
}
|
||||
|
||||
// === step 1 BS-53 state 检测 + 准备 release 调用 ===
|
||||
// BS-53: 检测 state=2 并提示用户, 后端 Actions/Release 直接覆盖为 1
|
||||
if (guardCtx.ctx?.modifiedAfterPublishForms?.some(f => f.startsWith(`${id}:`))) {
|
||||
|
||||
Reference in new issue
Block a user