-
Notifications
You must be signed in to change notification settings - Fork 73
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(weave): netrc entry handling in Weave JS SDK login method #3069
Conversation
Preview this PR with FeatureBee: https://beta.wandb.ai/?betaVersion=4548123596a830d1ea214ba166d6e63ac6545fde |
@@ -24,6 +24,9 @@ export async function login(apiKey: string, host?: string) { | |||
console.warn('No host provided, using default host:', defaultHost); | |||
host = defaultHost; | |||
} | |||
if (!apiKey) { |
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.
This is specifically for apiKey === ''
?
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.
@andrewtruong yes if apiKey is either null or not provided at all as an arg
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 think apiKey
is required
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 think there was no validation in place to enforce this requirement at runtime before, but should raise an error now by adding that !apiKey
check. I had tested with this script:
import * as weave from 'weave';
async function main() {
await weave.login()
await weave.init('examples');
console.log('Hello there, Weave JS');
}
main().catch(console.error);
Description
This PR resolves an issue in the Weave JS SDK's login method where the
.netrc
file was being modified or created incorrectly if theapiKey
arg was empty.Changes:
apiKey
is provided and non-emptyapiKey
is missing.netrc
entries unless bothhost
andapiKey
are valid and non-emptyKey fixes:
.netrc
entries remain intact and prevent removal of the password line for existing entries.netrc
fileTesting
To reproduce the issue:
.netrc
file containing valid machine entrieslogin
method is missing theapiKey
argFix testing:
.netrc
won't be created, if doesn't already exist, and noapiKey
is provided.netrc
remain intact whenweave.login()
is invoked