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

fix: Handle file-path in content #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Jim-Encord
Copy link

Failed for me and for customer FYLD.

@Jim-Encord Jim-Encord requested a review from a team as a code owner November 8, 2024 12:12
def check_is_not_path(cls, ssh_key_content: str | None) -> str | None:
if ssh_key_content is None:
return None
if os.path.exists(ssh_key_content):
Copy link
Author

Choose a reason for hiding this comment

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

Could try / except pathlib conversion to path but this doesn't raise exceptions and directly checks whether the value points to a file. (Could point to folder conceptually 🤔 )

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that I'd rather raise a more understandable error here instead of just magically solving the issue. Reason being that we're inheriting the env variables from the main SDK so wouldn't want to mess with that IMO.
So perhaps just

Suggested change
if os.path.exists(ssh_key_content):
if os.path.exists(ssh_key_content):
raise ValueError("It looks like your environment variable `ENCORD_SSH_KEY` is a file path and not the private ssh key content. Did you mean to set `ENCORD_SSH_KEY_PATH` instead?")

Copy link
Author

Choose a reason for hiding this comment

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

I disagree. I don't see why we wouldn't just magical resolve the issue? The point is not being right, it's making it work appropriately. If customers have their env keys in one place, then they may rely on that behaviour.

Copy link
Collaborator

@frederik-encord frederik-encord left a comment

Choose a reason for hiding this comment

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

Nice that you're chippin' in here Jim!

def check_is_not_path(cls, ssh_key_content: str | None) -> str | None:
if ssh_key_content is None:
return None
if os.path.exists(ssh_key_content):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that I'd rather raise a more understandable error here instead of just magically solving the issue. Reason being that we're inheriting the env variables from the main SDK so wouldn't want to mess with that IMO.
So perhaps just

Suggested change
if os.path.exists(ssh_key_content):
if os.path.exists(ssh_key_content):
raise ValueError("It looks like your environment variable `ENCORD_SSH_KEY` is a file path and not the private ssh key content. Did you mean to set `ENCORD_SSH_KEY_PATH` instead?")

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