-
Notifications
You must be signed in to change notification settings - Fork 1
fix: Strip quotes from env vars #51
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0e72808
fix: Strip quotes from env vars
SiddhantSadangi bf3b0ac
chore: Ignore line from mypy checks
SiddhantSadangi 8eba7fd
chore: Ignore line from mypy checks
SiddhantSadangi a763054
chore: Ignoring mypy unused ignores error
SiddhantSadangi 0ada996
Not stripping API_TOKEN
SiddhantSadangi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about going down the path of correcting the value of a critical secret like token for the user.
They should be always able to just remove the extra characters on their side?
I think it'd be less invasive to emit a warning when the authorization fails (or a project is not found), saying that that we detected that the value is wrapped in ''/"" and it's likely causing the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not correcting the token, we are just trimming the leading/training quotes.
I think it improves UX, as some methods in Python require the env variables to be enclosed in quotes (like any other string). However, this behavior does not carry over if the user uses a different method of setting variables that does not require quotes.
The client should be agnostic to how the variable was set, as long as the value is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Michał, we should not correct user input. It's trivial to properly export an env variable. The proposition to say "hey, I can see you have quotes in your API token, how about correcting this?" is better. Otherwise there is no end in how badly malformed input we can handle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that we do not need to strip quotes from the API TOKEN as quotes don't seem to make a difference, but if I try to pass

NEPTUNE_PROJECT
with quotes, I get aNeptuneUnauthorizedError
, which is definitely misleading:Can we strip quotes just from the project name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michalsosn , @kgodlewski - can we have a decision here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I haven't seen quotes being preserved anywhere besides the jupyter %env magic, but unfortunately it's too important to be ignored
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reason why API_TOKEN is accepted is because we're passing it through
base64.b64decode
which ignores most characters outside 0-9 a-z. You can even append a random string of ();:*& etc and it'll still work.
from
base64.b64decode
docs:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most users won't use neptune with notebooks, but we rely on notebooks for interactive tutorials. And this small change will enhance that experience and make life a bit easier for the few users who do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we're (maybe unintentionally) so lenient with the api token, refusing to trim the project name would not make too much sense
so I think the PR is good