ashish10alex / ashish10alex/vscode-dataform-tools
`post_operations` dry-run errors are not filtered through `errorDenylist`
- Dominant language
- TypeScript
- Stars
- 94
- Forks
- 16
- Avg merge
- 4m
- Merged PRs (30d)
- 7
Description
# `post_operations` dry-run errors are not filtered through `errorDenylist`
## Bug
The `errorDenylist` filtering that suppresses known false-positive dry-run errors is applied to `pre_operations` but **not** to `post_operations`, in both the inline diagnostics and the Compiled Query Preview panel.
This causes a persistent `(Post-Ops): Already Exists: Constraint primary key` error on any `type: "table"` model with a `post_operations` block that adds a primary key:
```
post_operations {
ALTER TABLE ${self()} ADD PRIMARY KEY (patient_id) NOT ENFORCED
}
```
The error is a **false positive** — when Dataform actually runs, it does `CREATE OR REPLACE TABLE`, so the constraint won't exist when the post-op executes. But the extension's dry run validates against the *live* table, which already has the constraint from a previous run.
## Affected files
### 1. `src/setDiagnostics.ts`
Pre-ops errors are checked against `errorDenylist` (lines 73-80), but post-ops errors are pushed unconditionally (lines 82-87):
```javascript
// Pre-ops: filtered ✅
if (errorMeta?.preOpsError?.hasError) {
constants_1.errorDenylist.some((errorMessage) => {
errorInPreOpsDenyList = (errorMeta?.preOpsError?.message.includes(errorMessage) || false);
});
if (!errorInPreOpsDenyList) {
diagnostics.push(preOpsDiagnostic);
}
}
// Post-ops: NOT filtered ❌
if (errorMeta?.postOpsError?.hasError) {
diagnostics.push(postOpsDiagnostic);
}
```
### 2. `src/views/register-preview-compiled-panel.ts`
Same pattern — pre-ops checks `!errorInPreOpsDenyList`, post-ops does not:
```javascript
let errorMessage = (preOpsDryRunResult?.error.message && !errorInPreOpsDenyList ? ... : "") // ✅
+ (postOpsDryRunResult?.error.message ? "(Post operations): " + ... : "") // ❌
```
### 3. `src/constants.ts`
`errorDenylist` should include `"Already Exists: Constraint"` to cover the primary key false positive.
## Suggested fix
1. Add `"Already Exists: Constraint"` to `errorDenylist` in `constants.ts`
2. Apply the same denylist check to `postOpsError` in `setDiagnostics.ts`
3. Apply the same denylist check to `postOpsDryRunResult` in `register-preview-compiled-panel.ts`
## Environment
- Extension version: 0.20.0
- Model type: `table` (not incremental)
Contributor guide
Assessment
This issue has not been assessed yet.