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

Multiline values Failed #77

Open
Kingg22 opened this issue Sep 13, 2024 · 1 comment · May be fixed by #78
Open

Multiline values Failed #77

Kingg22 opened this issue Sep 13, 2024 · 1 comment · May be fixed by #78

Comments

@Kingg22
Copy link

Kingg22 commented Sep 13, 2024

Context:

  • Spring boot 3.3.3
  • Java JDK 21
  • Maven 3.9.5
  • Spring dotenv 4.0.0

What happened?
Using a .env file I put my rsa key in the form JWT_PRIVATE="-----BEGIN PRIVATE KEY-----
......
-----END PRIVATE KEY-----"
and the error occurs:

14:29:57.810 [main] ERROR org.springframework.boot.SpringApplication -- Application run failed
io.github.cdimascio.dotenv.DotenvException: Malformed entry

I ran with ' ', with \n and the only solution I found was to use PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nKh9NV...\n-----END RSA PRIVATE KEY-----\n" as the dotenv faq says.

I report it here since the error indicates the exception from here and not spring dotenv.
Captura de pantalla 2024-09-13 144009
With \n and ' '
Captura de pantalla 2024-09-13 144044

In this you can see that when using JWT_PRIVATE as a long string it does pass and the error is the following JWT_PUBLIC
Captura de pantalla 2024-09-13 144120

Attentive to your response or solution. Thanks for all.

@ipalbeniz
Copy link

ipalbeniz commented Oct 2, 2024

After reviewing the tests, it seems that the only way to define a multiline value is using this format: MULTI_LINE=hello\nworld (.env).

However, there appears to be an issue in the unit test. The test expects a multiline string with escaped newlines (\\n), but it should handle actual newlines (\n) instead (BasicTests.java).

A workaround could involve defining the multiline values in the format MULTI_LINE=hello\nworld and then replacing the escaped newlines with actual newlines using .replace("\\n", "\n") in java code. In any case, it would be best to wait for a fix for this issue.

@melegati melegati linked a pull request Oct 25, 2024 that will close this issue
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 a pull request may close this issue.

2 participants