Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@petrotiurin
Copy link
Contributor

Details

Fixed TypeScript SDK config file path expansion to properly handle tilde (~) in paths. The issue was that Node.js's fs module doesn't natively expand tilde paths, so ~/.opik.config wasn't being found.

Implementation:

  • Changed default config path from "~/.opik.config" to path.join(os.homedir(), ".opik.config") for direct absolute path resolution
  • Added expandPath() function using regex pattern /^~(?=$|\/|\\)/ to handle tilde expansion in OPIK_CONFIG_PATH environment variable
  • Applied path expansion before all filesystem operations (fs.existsSync, fs.readFileSync)

The regex pattern ensures we only expand ~ at the start of the path when followed by end of string, forward slash, or backslash (cross-platform support).

Change checklist

  • User facing
  • Documentation update

Issues

  • OPIK-4211

Testing

Added unit test should expand tilde in OPIK_CONFIG_PATH that verifies:

  • Tilde expansion works correctly with mocked filesystem
  • Config file is properly loaded from expanded path
  • All config values (apiKey, apiUrl, workspaceName, projectName) are correctly parsed

To test manually:

  1. Set OPIK_CONFIG_PATH=~/.opik.config (or any path starting with ~)
  2. Create config file at the expanded location
  3. Verify SDK loads config correctly

Documentation

N/A - No documentation changes required. This is a bug fix that maintains backward compatibility.

…onfig

Add expandPath function to handle tilde expansion in OPIK_CONFIG_PATH environment variable. The default config path now uses path.join for absolute path resolution, and custom paths with tilde are properly expanded using regex pattern matching.

Implements OPIK-4211: [TS SDK] Default ~/.opik.config config path is not used
@github-actions github-actions bot added tests Including test files, or tests related like configuration. typescript *.ts *.tsx TypeScript SDK labels Feb 3, 2026
@petrotiurin petrotiurin marked this pull request as ready for review February 3, 2026 16:58
@petrotiurin petrotiurin requested a review from a team as a code owner February 3, 2026 16:58
@petrotiurin petrotiurin requested a review from awkoy February 3, 2026 17:35
Copy link
Contributor

@awkoy awkoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@petrotiurin petrotiurin merged commit 1361ef4 into main Feb 4, 2026
20 of 21 checks passed
@petrotiurin petrotiurin deleted the petrot/OPIK-4211-fix-config-path-expansion branch February 4, 2026 09:38
awkoy pushed a commit that referenced this pull request Feb 5, 2026
…onfig (#5044)

Add expandPath function to handle tilde expansion in OPIK_CONFIG_PATH environment variable. The default config path now uses path.join for absolute path resolution, and custom paths with tilde are properly expanded using regex pattern matching.

Implements OPIK-4211: [TS SDK] Default ~/.opik.config config path is not used
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Including test files, or tests related like configuration. TypeScript SDK typescript *.ts *.tsx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants