Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug message if no encoding is specified #735

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

anthonyshibitov
Copy link
Contributor

If no encoding is specified in the options, debug will alert the user that UTF-8 will be used as the default.

From my perspective, there were two resolutions to this issue.

  1. If no encoding is specified in the options, and debug is enabled, a UTF-8 validation function will determine if the .env file is is UTF-8, and warn the user if it fails.
  2. If no encoding is specified in the options, and debug is enabled, a warning will show that UTF-8 is used as the default encoding.

While UTF-8 is one of the few encodings that can be reliably validated without using heuristics, the code to do so is generally not compact or easy to understand, and would require running the validation function on the entire string, in addition to being parsed.

The original issue this fix stems from was a mismatched encoding for .dotenv not conforming with the default UTF-8 (UTF-16-LE was the culprit). Implementing an entire UTF-8 validator function seems to be overkill (both computationally, and code clarity wise) for, from what I can tell, is not a common issue. I think alerting the user of the default encoding only in debug mode is a good compromise to avoid unnecessary bloat.

Please let me know your thoughts. This is my first open source contribution, so any and all critique is welcome.

Thank you! :)

Closes #657

If no encoding is specified in the options, debug will alert the user that
UTF-8 will be used as the default.

Closes motdotla#657
@motdotla
Copy link
Owner

This is a reasonable approach, but what we are going to do instead is add a debug command to dotenv-vault.

It will output a lot of helpful text if you are:

  1. missing a .env file
  2. .env file is in the wrong encoding
  3. etc, etc

@motdotla motdotla force-pushed the master branch 4 times, most recently from 01fa9ef to ef48935 Compare May 30, 2023 16:15
@motdotla
Copy link
Owner

we started moving the more detailed information mentioned above into dotenvx - https://github.com/dotenvx/dotenvx

but this is still a great and quick addition. will release as part of next release for dotenv

@motdotla motdotla merged commit 630d2a0 into motdotla:master Jan 18, 2024
Vylpes pushed a commit to Vylpes/card-drop that referenced this pull request Jan 22, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [dotenv](https://github.com/motdotla/dotenv) | dependencies | patch | [`16.3.1` -> `16.3.2`](https://renovatebot.com/diffs/npm/dotenv/16.3.1/16.3.2) |

---

### Release Notes

<details>
<summary>motdotla/dotenv (dotenv)</summary>

### [`v16.3.2`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1632-2024-01-18)

[Compare Source](motdotla/dotenv@v16.3.1...v16.3.2)

##### Added

-   Add debug message when no encoding set [#&#8203;735](motdotla/dotenv#735)

##### Changed

-   Fix output typing for `populate` [#&#8203;792](motdotla/dotenv#792)
-   Use subarray instead of slice [#&#8203;793](motdotla/dotenv#793)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/149
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
Vylpes pushed a commit to Vylpes/vylbot-app that referenced this pull request Jan 31, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [dotenv](https://github.com/motdotla/dotenv) | dependencies | minor | [`16.3.1` -> `16.4.1`](https://renovatebot.com/diffs/npm/dotenv/16.3.1/16.4.1) |

---

### Release Notes

<details>
<summary>motdotla/dotenv (dotenv)</summary>

### [`v16.4.1`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1641-2024-01-24)

[Compare Source](motdotla/dotenv@v16.4.0...v16.4.1)

-   Patch support for array as `path` option [#&#8203;797](motdotla/dotenv#797)

### [`v16.4.0`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1640-2024-01-23)

[Compare Source](motdotla/dotenv@v16.3.2...v16.4.0)

-   Add `error.code` to error messages around `.env.vault` decryption handling [#&#8203;795](motdotla/dotenv#795)
-   Add ability to find `.env.vault` file when filename(s) passed as an array [#&#8203;784](motdotla/dotenv#784)

### [`v16.3.2`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1632-2024-01-18)

[Compare Source](motdotla/dotenv@v16.3.1...v16.3.2)

##### Added

-   Add debug message when no encoding set [#&#8203;735](motdotla/dotenv#735)

##### Changed

-   Fix output typing for `populate` [#&#8203;792](motdotla/dotenv#792)
-   Use subarray instead of slice [#&#8203;793](motdotla/dotenv#793)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/397
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
Vylpes pushed a commit to Vylpes/Droplet that referenced this pull request Feb 5, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [dotenv](https://github.com/motdotla/dotenv) | dependencies | minor | [`16.3.1` -> `16.4.1`](https://renovatebot.com/diffs/npm/dotenv/16.3.1/16.4.1) |

---

### Release Notes

<details>
<summary>motdotla/dotenv (dotenv)</summary>

### [`v16.4.1`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1641-2024-01-24)

[Compare Source](motdotla/dotenv@v16.4.0...v16.4.1)

-   Patch support for array as `path` option [#&#8203;797](motdotla/dotenv#797)

### [`v16.4.0`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1640-2024-01-23)

[Compare Source](motdotla/dotenv@v16.3.2...v16.4.0)

-   Add `error.code` to error messages around `.env.vault` decryption handling [#&#8203;795](motdotla/dotenv#795)
-   Add ability to find `.env.vault` file when filename(s) passed as an array [#&#8203;784](motdotla/dotenv#784)

### [`v16.3.2`](https://github.com/motdotla/dotenv/blob/HEAD/CHANGELOG.md#1632-2024-01-18)

[Compare Source](motdotla/dotenv@v16.3.1...v16.3.2)

##### Added

-   Add debug message when no encoding set [#&#8203;735](motdotla/dotenv#735)

##### Changed

-   Fix output typing for `populate` [#&#8203;792](motdotla/dotenv#792)
-   Use subarray instead of slice [#&#8203;793](motdotla/dotenv#793)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/Droplet/pulls/261
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
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.

Does not raise an error when parsing a wrong encoding (nodejs)
2 participants