Commit 1a6610d
fix:
* fix: patch hardcoded `__dirname` in `dbt-tools` bundle so `altimate-dbt` works in published releases
`bun build` replaces `__dirname` with a compile-time constant when bundling
`python-bridge` (transitive dep of `@altimateai/dbt-integration`). In CI this
bakes `/home/runner/work/...` into the bundle, causing `altimate-dbt build`
and all Python-bridge commands to fail with ENOENT on every user's machine.
Fix:
- Copy `node_python_bridge.py` into `dist/` alongside `index.js`
- Post-process the bundle to replace the frozen path with `import.meta.dirname`
- Fail the build if the patch pattern isn't found (safety net)
- Add CI smoke test to prevent regression
Broken since PR #201. Closes #466.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: address PR review — add Node 18 fallback and broaden path assertions
- Use `fileURLToPath(import.meta.url)` fallback for Node < 20.11.0
- Broaden smoke test and build integrity checks to catch any hardcoded
absolute path (Unix + Windows), not just `home/runner`
* fix: drop Node 18 fallback — `path` is not in scope before `__dirname` in bundle
GLM-5 review correctly identified that `path` is defined AFTER `__dirname`
in the bundled output, so the `path.dirname(fileURLToPath(...))` fallback
would throw `ReferenceError` on Node < 20.11.0.
Since Node 18 is EOL (April 2025), use `import.meta.dirname` unconditionally.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: copy `node_python_bridge.py` in `publish.ts` so npm tarball includes it
`copyAssets` copied `dbt-tools/dist/index.js` but not the `.py` file
the patched `__dirname` resolves to. Without this, the fix would still
break in published packages.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: spread real `child_process` in `mock.module` to prevent `execFileSync` leak
`mock.module("child_process")` in `dbt-cli.test.ts` only provided `execFile`,
causing `dbt-resolve.test.ts` to fail with `Export named 'execFileSync' not found`
when Bun leaks the mock across test files.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: use __require fallback for __dirname to support Node < 20.11.0
`import.meta.dirname` is unavailable before Node 20.11.0. The previous
fallback was dropped because `path`/`fileURLToPath` weren't in scope at
that point in the bun-generated __commonJS IIFE. Using `__require` (a
module-level closure bun always emits) works at any Node version.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* style: format `dbt-cli.test.ts` and `publish.ts` with Prettier
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add adversarial tests for `__dirname` patch and build integrity
22 tests covering regex edge cases, runtime resolution, idempotency,
CI smoke test parity, and built bundle invariants.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address code review — existence check, comment fix, better diagnostics
- Add `existsSync` check before copying `node_python_bridge.py` with
a clear error message if the file is missing from the dependency
- Fix misleading comment that said "no fallback needed" while fallback
code existed — now accurately describes the `__require` fallback
- Log the nearest `__dirname` match on pattern mismatch to aid debugging
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: expand adversarial tests to 43 cases covering runtime, publish, and mutation
New test categories:
- Script execution: verify exit codes, progress output, build determinism
- Bundle runtime structure: `__require` origin, `__commonJS` scope, spawn chain
- Publish pipeline: patched artifacts integrity before copy
- Mutation testing: verify guards catch removal of key fix components
- Regex performance: no catastrophic backtracking on 100KB+ input
- Malformed inputs: unicode, spaces, special chars, surrounding code preservation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: eliminate flaky CI test failures in dispatcher, dbt, and tracer tests
Root causes:
- `dispatcher.test.ts`: Bun's multi-file runner leaks `_ensureRegistered`
hook from other files' `native/index.ts` imports. `reset()` clears
handlers but not the hook, so `call()` triggers lazy registration
instead of throwing. Fix: clear hook in `beforeEach`.
- `dbt-first-execution.test.ts`: `mock.module` for DuckDB leaked across
files. Fix: spread real module exports + ensure native/index.ts import.
- `tracing-adversarial-final.test.ts`: 50ms snapshot waits too tight for
CI under load. Fix: increase to 200ms/300ms.
Result: 0 failures in full suite (4961 pass, 340 skip).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: replace environment-coupled `runner` assertion with directory existence check
Address CodeRabbit review: `expect(dirname).not.toContain("runner")`
would fail on GitHub CI where test runs under `/home/runner/`. Use
`existsSync(dirname)` to validate the directory is real instead.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Michiel De Smet <mdesmet@gmail.com>
Co-authored-by: anandgupta42 <anand@altimate.ai>
Co-authored-by: anandgupta42 <93243293+anandgupta42@users.noreply.github.com>altimate-dbt commands fail with hardcoded CI path in published binary (#467)1 parent 0e6bb70 commit 1a6610d
File tree
10 files changed
+662
-116
lines changed- .github/workflows
- packages
- dbt-tools
- script
- test
- opencode
- script
- test/altimate
10 files changed
+662
-116
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
157 | 176 | | |
158 | 177 | | |
159 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
4 | 7 | | |
5 | 8 | | |
6 | | - | |
7 | | - | |
8 | | - | |
| 9 | + | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
0 commit comments