-
Notifications
You must be signed in to change notification settings - Fork 68
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
Benthos Fails to Fully Process Environment Values Containing # #147
Comments
Hey @pv123444, can you please confirm that |
It works for values with #, but when using strings with special characters
like \n or \t, they are treated as escape characters and don't work as
expected.
…On Tue, Dec 24, 2024 at 6:31 PM Mihai Todor ***@***.***> wrote:
Hey @pv123444 <https://github.com/pv123444>, can you please confirm that
MY_ENV_VAR="abc#def#ghi" works for you? As mentioned on Slack, we can
potentially look into adjusting the env file parser, but we need to know
which standard to follow.
—
Reply to this email directly, view it on GitHub
<#147 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BN6AYE6TWSLYM62W74I72CL2HFLMPAVCNFSM6AAAAABUEGLYVOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRRGEYDMNRVGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
*Disclaimer:*
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
addressee(s) and may contain confidential or privileged information. If you
are not the intended recipient, please notify the sender at Crest Data
Systems immediately and destroy all copies of this message and any
attachments.
|
I'm not sure I follow... Can you please provide an example? Also, as mentioned, if you believe we need to change something, please provide a reference to a detailed spec that we should follow. I added the following in
And then running this YAML: input:
generate:
count: 1
mapping: |
root = "${FOOBAR}" I get: $ benthos run -e foo.env foo.yaml
INFO Running main config from specified file @service=redpanda-connect benthos_version="" path=foo.yaml
INFO Listening for HTTP requests at: http://0.0.0.0:4195 @service=redpanda-connect
INFO Launching a Redpanda Connect instance, use CTRL+C to close @service=redpanda-connect
INFO Input type generate is now active @service=redpanda-connect label="" path=root.input
INFO Output type stdout is now active @service=redpanda-connect label="" path=root.output
abc def
ghi
INFO Pipeline has terminated. Shutting down the service @service=redpanda-connect Also, note that we do support raw strings as well via |
If we support raw strings, that’s great! However, I’d like to know if there’s a way to store an environment variable without using string or raw string format, but still fetch the exact value as is. For example, when I set the environment variable FOOBAR=abc\tdef\nghi, I’d like to retrieve( env("FOOBAR") ) it in its literal form with the escape sequences intact, as abc\tdef\nghi, without interpreting them as tab or newline characters. Is there a specific method we can use to achieve this? If there’s a detailed specification or guide that outlines how to handle such cases, I’d greatly appreciate a reference to it. |
Setting For |
Hello @mihaitodor |
@pv123444 the logging can be misleading since it needs to do all sorts of string escaping. This looks fine to me: input:
generate:
count: 1
mapping: root = env("FOO")
output:
stdout: {} $ export FOO="##%'#Databee##\""
$ rpk connect run test.yaml
...
##%'#Databee##"
INFO Pipeline has terminated. Shutting down the service @service=redpanda-connect With an env file, you'll have to use a raw string:
$ rpk connect run -e test.env test.yaml
....
##%'#Databee##"
INFO Pipeline has terminated. Shutting down the service @service=redpanda-connect Not ideal if you have a Have you considered base64-encoding these passwords first? It might save you a lot of headaches... |
Thanks @mihaitodor for your support , |
@mihaitodor I found that Benthos is unable to interpolate the Bloblang expression for the
This issue likely occurs because the Additionally, if we decide to use the base64 encoding approach, we would still need the Bloblang expression to decode the base64 credentials. How should we handle base64-encoded environment variables for |
@abheda-crest Using I think I have a workaround for
This config: input:
generate:
count: 1
mapping: root = env("FOO")
processors:
- log:
message: |
|${FOO}|
- log:
message: '|${! content() }|'
output:
drop: {} prints
Note: I added the Basically, you'd have to parse your secrets and:
Would that work for you? If not, happy to look into adjusting the parser, but we'd need to know which standard to follow rather than a list of examples which don't currently work as expected. |
Thanks, @mihaitodor, We've attempted the workaround you mentioned, but it doesn't work when trying to use environment variables i.e. To summarize: We'll store the credentials as environment variables, which will then be used for API calls. The authentication method will vary based on the configuration. This can include standard methods like Some potential solutions I can think of are:
Please share your feedback on these potential solutions, or suggest any additional ones you may have. |
I think you might be hitting some yaml parser issues if you simply do foo: |
${FOO} or maybe this if the above adds a newline: foo: >-
${FOO}
That's a heavy lift unfortunately. We could consider adding interpolation support for certain fields, like maybe some of the auth stuff. I think there was another issue about that a while back. If it can be scoped down to a few fields, happy to track that as part of a separate issue.
These are good suggestions, but they won't be a quick enhancement. I'll leave the issue open and see when we'll get a chance to figure out what can be done here. At the very least, we need more docs to cover some of these edge cases. |
Thanks, @mihaitodor. We also believe that adopting the third approach, |
Slack Reference:
Channel: Redpanda Community
Message Link: Slack Message
Issue:
We found that Benthos fails to fully process environment variable values containing the # character. When fetching such values, it stops reading at the # and ignores the remaining part of the value.
Example:
Given an environment variable set as:
MY_ENV_VAR=abc#def#ghi
Benthos only reads abc, and everything after the first # (def#ghi) is ignored.
Expected Behavior:
Benthos should read and process the entire value, abc#def#ghi.
Actual Behavior:
Benthos only reads abc, causing issues for workflows that need the full value.
The text was updated successfully, but these errors were encountered: