Skip to content

fix: handle non-string values in jsonToEnv and fix file extension#10

Merged
lemtoc merged 2 commits into
mainfrom
refactor/v0.6.0
Jan 27, 2026
Merged

fix: handle non-string values in jsonToEnv and fix file extension#10
lemtoc merged 2 commits into
mainfrom
refactor/v0.6.0

Conversation

@lemtoc
Copy link
Copy Markdown
Owner

@lemtoc lemtoc commented Jan 27, 2026

Issue

N/A - Fix runtime errors and documentation consistency issues identified in code review

Changes

  • Fix jsonToEnv function to safely handle non-string values from AWS Secrets Manager
  • Update type signature from Record<string, string> to Record<string, unknown>
  • Add String() conversion for numbers, booleans, objects, null, and undefined values
  • Fix help message to correctly reference .e2smrc.jsonc instead of .e2smrc.json
  • Add comprehensive test cases for non-string value conversion

Verification

  • Tests pass successfully
  • No lint/type errors
  • No breaking changes introduced
  • Changeset file created (not needed - bug fixes only)

Additional Notes

This PR addresses code review feedback to improve robustness when handling secrets that may have been created or modified outside this tool. The jsonToEnv function now gracefully converts any JSON value type to a string representation, preventing runtime errors when .replace() is called on non-string values.

The help message fix ensures consistency with the actual file extension used throughout the codebase and documentation.

- fix jsonToEnv to safely convert non-string values to strings
- update type signature from Record<string, string> to Record<string, unknown>
- add String() conversion for numbers, booleans, objects, null, and undefined
- fix help message to show .e2smrc.jsonc instead of .e2smrc.json
- add comprehensive tests for non-string value conversion
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 27, 2026

⚠️ No Changeset found

Latest commit: d263ac9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes runtime errors and improves documentation consistency by addressing issues in the jsonToEnv function and help text. The changes prevent errors when AWS Secrets Manager returns non-string values and correct a file extension reference.

Changes:

  • Modified jsonToEnv to handle non-string values (numbers, booleans, null, undefined, objects) by converting them to strings
  • Updated type signature from Record<string, string> to Record<string, unknown> to reflect the broader input support
  • Fixed help message to reference .e2smrc.jsonc instead of .e2smrc.json for consistency

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/lib/env.ts Updated jsonToEnv function to safely convert non-string values to strings before processing
src/lib/env.test.ts Added comprehensive tests for number, boolean, null, undefined, and object value conversions
src/index.ts Corrected help message to reference .e2smrc.jsonc file extension

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/env.ts Outdated
Comment thread src/lib/env.test.ts Outdated
- use JSON.stringify for objects and arrays instead of String()
- preserve data structure in .env output for complex types
- add test case for array value conversion
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lemtoc lemtoc merged commit 2d52e27 into main Jan 27, 2026
10 checks passed
@lemtoc lemtoc deleted the refactor/v0.6.0 branch January 27, 2026 07:08
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.

2 participants