Skip to content

fix: [PRO-469] remove double quotes from .env file generation#114

Merged
dudutwizer merged 2 commits into
mainfrom
dt-20251210-pro-469
Dec 10, 2025
Merged

fix: [PRO-469] remove double quotes from .env file generation#114
dudutwizer merged 2 commits into
mainfrom
dt-20251210-pro-469

Conversation

@dudutwizer

@dudutwizer dudutwizer commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

Notion Ticket

https://www.notion.so/xpander/CLI-Bug-env-file-being-generated-with-strings-causing-serious-issue-2c529ef830b380a29936f1ab61d91a7a

Summary

  • Fixed .env file generation to write environment variables without double quotes
  • Changed from KEY="value" format to standard KEY=value format
  • Added comprehensive test coverage for environment file generation

Problem

The CLI was generating .env files with double quotes around values:

XPANDER_API_KEY="actual-api-key"
XPANDER_ORGANIZATION_ID="org-id"
XPANDER_AGENT_ID="agent-id"

This caused serious issues because many environment variable parsers treat the quotes as part of the value, leading to authentication failures and configuration problems.

Solution

Updated initialize.ts:257-260 to remove template literal quote wrapping:

Before:

const envVars: any = {
  XPANDER_API_KEY: `"${client.apiKey}"`,
  XPANDER_ORGANIZATION_ID: `"${client.orgId!}"`,
  XPANDER_AGENT_ID: `"${agentId}"`,
};

After:

const envVars: any = {
  XPANDER_API_KEY: client.apiKey,
  XPANDER_ORGANIZATION_ID: client.orgId!,
  XPANDER_AGENT_ID: agentId,
};

Now generates standard format:

XPANDER_API_KEY=actual-api-key
XPANDER_ORGANIZATION_ID=org-id
XPANDER_AGENT_ID=agent-id

Test Plan

  • Build passes: npm run build
  • All 28 tests pass (4 new tests added) ✅
  • ESLint passes with no errors ✅
  • Coverage maintained at 96.78% ✅
  • CLI commands work: node lib/index.js --version
  • CLI commands work: node lib/index.js --help
  • New test file validates env format: test/env-generation.test.ts

Test Coverage Added

Created test/env-generation.test.ts with 4 comprehensive test cases:

  1. Environment variables written without double quotes
  2. Standard KEY=value format validation
  3. Special characters handling without quotes
  4. Empty values without quotes

🤖 Generated with Claude Code


Note

Stops quoting values in generated .env and adds tests to enforce standard KEY=value format.

  • Agent Initialization (.env generation)
    • Remove quote-wrapping when setting XPANDER_API_KEY, XPANDER_ORGANIZATION_ID, and XPANDER_AGENT_ID in src/commands/agent/interactive/initialize.ts to emit KEY=value (no quotes).
    • Merge logic writes only missing/placeholder values using unquoted values.
  • Tests
    • Add test/env-generation.test.ts with cases verifying unquoted values, standard KEY=value format, special character handling, and empty values.

Written by Cursor Bugbot for commit 592a183. This will update automatically on new commits. Configure here.

Fixed environment variable generation to write values without double
quotes, following standard .env file conventions. This resolves an issue
where secrets were being wrapped in quotes and causing authentication
and configuration problems.

Changes:
- Updated initialize.ts to remove quote wrapping from env values
- Added comprehensive tests for .env file generation
- Verified standard KEY=value format (not KEY="value")

Test coverage:
- Added test/env-generation.test.ts with 4 test cases
- All 28 tests pass (96.78% coverage maintained)
- Build and lint checks pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
@notion-workspace

Copy link
Copy Markdown

Synced yarn.lock from main branch to fix build mutation errors in CI.
The lockfile was out of sync causing the self-mutation check to fail.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>

@xpander-moriel xpander-moriel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pay attention @dudutwizer
We're not using npm in the cli, we use yarn :)

@dudutwizer
dudutwizer merged commit 09e5fa8 into main Dec 10, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants