diff --git a/apps/sim/lib/workspace-source/application/findings.ts b/apps/sim/lib/workspace-source/application/findings.ts index 6f6fb1d6c75..f8b74babd41 100644 --- a/apps/sim/lib/workspace-source/application/findings.ts +++ b/apps/sim/lib/workspace-source/application/findings.ts @@ -71,7 +71,8 @@ type FindingLocation = Pick { expect(report.diagnostics ?? []).toEqual([]) }) + it('leaves out a key-taken finding the compile pins to a line of a workflow an apply sends by its base', async () => { + mockRequest.mockResolvedValue( + dry( + [{ kind: 'workflow', key: 'ingest', action: 'noop' }], + [ + { + code: 'E_NAME_TAKEN', + severity: 'error', + message: 'Two blocks are named "Agent".', + file: 'workflows/ingest/workflow.ts', + line: 1, + kind: 'workflow', + key: 'ingest', + }, + ] + ) + ) + + await run('status') + + const report = printed() + expect(report.plan).toMatchObject({ errors: 0 }) + expect(report.diagnostics ?? []).toEqual([]) + }) + it('keeps a plan refusal about a workflow an apply sends by its base: status counts the error the apply refuses with', async () => { mockRequest.mockResolvedValue( dry( @@ -670,6 +695,30 @@ describe('workspaces source status', () => { expect(report.diagnostics).toEqual([expect.objectContaining({ code: 'E_PLAN_REF_DELETED' })]) }) + it('keeps a key-taken refusal pinned to the folder of a workflow an apply sends by its base', async () => { + mockRequest.mockResolvedValue( + dry( + [{ kind: 'workflow', key: 'ingest', action: 'noop' }], + [ + { + code: 'E_NAME_TAKEN', + severity: 'error', + message: 'The workflow key "ingest" belongs to "Other".', + file: 'workflows/ingest/workflow.ts', + kind: 'workflow', + key: 'ingest', + }, + ] + ) + ) + + await run('status') + + const report = printed() + expect(report.plan).toMatchObject({ errors: 1 }) + expect(report.diagnostics).toEqual([expect.objectContaining({ code: 'E_NAME_TAKEN' })]) + }) + it('keeps lint findings on a workflow edited here, which an apply sends whole', async () => { write('workflows/ingest/workflow.ts', INGEST.replace("'Ingest'", "'Ingest v2'")) mockRequest.mockResolvedValue( diff --git a/packages/workspace-code/src/diagnostics/codes.ts b/packages/workspace-code/src/diagnostics/codes.ts index 3650c5654e4..08c83321f2a 100644 --- a/packages/workspace-code/src/diagnostics/codes.ts +++ b/packages/workspace-code/src/diagnostics/codes.ts @@ -358,13 +358,14 @@ const SHARED_CODE_SET: ReadonlySet = new Set(SHARED_CODES) /** * Whether a finding comes from evaluating a workflow folder's files (compile, lint): a workflow - * pipeline code, or one {@link SHARED_CODES} holds pinned to a file. The server reports these only - * for a folder sent whole; a workspace code (a plan check such as `E_PLAN_REF_DELETED`, a held - * reference, a stale resource) can be about any folder, sent whole or by its base. + * pipeline code, or one {@link SHARED_CODES} holds pinned to a line of a file. The server reports + * these only for a folder sent whole; a workspace code (a plan check such as `E_PLAN_REF_DELETED`, + * a held reference, a stale resource) can be about any folder, sent whole or by its base. A + * workspace finding of a shared code points at the resource's file but never at a line in it. */ -export function isFolderEvaluationFinding(finding: { code: string; file?: string }): boolean { +export function isFolderEvaluationFinding(finding: { code: string; line?: number }): boolean { if (OWN_CODE_SET.has(finding.code)) return false - return !SHARED_CODE_SET.has(finding.code) || finding.file !== undefined + return !SHARED_CODE_SET.has(finding.code) || finding.line !== undefined } /**