#4591·hatchet

[BUG] TypeScript SDK: ConfigLoader.loadYamlConfig never finds .hatchet.yaml — silently ignores the config file

Author: chandan-1427Created Aug 2, 2026Updated Sep 30, 2026
Labelsaccepted

Describe the issue

ConfigLoader.loadYamlConfig (sdks/typescript/src/util/config-loader/config-loader.ts:217-240) resolves the YAML config path with:

typescript
const configFile = readFileSync(
  p.join(__dirname, path ?? this.default_yaml_config_path),
  'utf8'
);

default_yaml_config_path is already an absolute path (path.join(process.cwd(), '.hatchet.yaml')). path.join does not treat a second absolute-looking argument as a root reset the way path.resolve would — it concatenates and normalizes both segments. So this line resolves to something like:

<sdk-install-dir>/dist/util/config-loader/home/<user>/project/.hatchet.yaml

instead of /home/<user>/project/.hatchet.yaml. That path never exists, so readFileSync always throws ENOENT. Because path (the caller-supplied override) is undefined in the default case, the catch block swallows the error and returns undefined — so a real .hatchet.yaml sitting in the project root is silently never loaded, with no warning or error surfaced to the user. The app falls back to env vars / defaults only.

The same join happens even when a caller explicitly passes options.config_path to HatchetClient — it gets resolved relative to the SDK's own install directory (__dirname, inside node_modules when installed as a dependency) rather than the caller's project directory, so an explicit relative config_path is also broken.

Notably, the existing test suite only ever exercises this with paths like ./fixtures/.hatchet.yaml, which happen to resolve correctly only because the fixture file lives inside src/util/config-loader/fixtures/ — i.e. relative to __dirname of the module itself, not a real caller's project. There's also a skipped test (config-loader.test.ts:143, xit('should attempt to load the root .hatchet.yaml config'...)) with the comment "i'm not sure the best way to test this", suggesting this path was never actually verified end-to-end.

Environment

  • SDK: TypeScript (sdks/typescript), current main (commit 2ff0b1b8a)
  • Engine: N/A — this is a pure client-side config-loading bug, no engine/network interaction needed to reproduce

Expected behavior

A .hatchet.yaml file present at the process's current working directory (per the docs / DEFAULT_CONFIG_FILE convention) should be read and its values applied, taking precedence over env vars, exactly as the (currently skipped) test intends.

Steps to Reproduce

  1. git checkout 2ff0b1b8a
  2. cd sdks/typescript
  3. Add the following test file (or run inline) and execute npx jest config-loader.default-path:
typescript
import * as fs from 'fs';
import * as path from 'path';
import { ConfigLoader } from './config-loader';

describe('ConfigLoader.loadYamlConfig default path resolution', () => {
  it('loads a .hatchet.yaml that actually exists at the caller cwd', () => {
    const cwdConfigPath = path.join(process.cwd(), '.hatchet.yaml');
    fs.writeFileSync(cwdConfigPath, 'namespace: from-cwd-yaml\n');

    try {
      const config = ConfigLoader.loadYamlConfig();
      expect(config).toEqual({ namespace: 'from-cwd-yaml' });
    } finally {
      fs.unlinkSync(cwdConfigPath);
    }
  });
});
  1. Observe:
Expected: {"namespace": "from-cwd-yaml"}
Received: undefined

The file exists at exactly the documented default location and is still never read.

Additional context

  • Root cause: path.join(__dirname, <absolute-or-caller-relative-path>) in config-loader.ts:220 instead of resolving relative to process.cwd() (or using path.resolve semantics intentionally, if __dirname-relative was ever the real intent — though that would make the "default config file in your project root" feature meaningless for anyone consuming the SDK as an npm dependency).
  • Confirmed no other place recomputes/loads this file — loadClientConfig is the sole call site feeding HatchetClient construction (src/v1/client/client.ts:138) and HatchetInstrumentor (src/opentelemetry/instrumentor.ts:201).
  • Checked for duplicates via GitHub search API (config_path, loadYamlConfig, ConfigLoader, .hatchet.yaml) — no existing open issue/PR covers this.

AI Disclosure
  • I acknowledge that an LLM was used in the creation of this Issue, in accordance with Hatchet's AI_POLICY.md.

  • Details: Claude Code was used to scan the TypeScript SDK for high-churn/high-risk files, trace the path.join(__dirname, ...) root cause, and write/run the reproduction test confirming the file is never loaded. Reviewed and verified manually before submission.