-
Notifications
You must be signed in to change notification settings - Fork 78
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
Invalid SFDX auth URL when running org:login:sfdx-url #2629
Comments
Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support. |
The issue is with the regular expression used to parse the URL in Also, make sure the file you use is not Unicode. |
We use a regex to validate the auth URL format is correct: the clientSecret is optional so that should be fine, I wonder if the refresh token and/org instance url has a character not allowed by the regex... Since you can't share the URL you might need to manually check this, if you have node you can use this code to verify it: const sfdxAuthUrl = '<auth-url>'
console.log(sfdxAuthUrl.match(/^force:\/\/([a-zA-Z0-9._-]+={0,2}):([a-zA-Z0-9._-]*={0,2}):([a-zA-Z0-9._-]+={0,2})@([a-zA-Z0-9._-]+)/)?.index) if there's a match it should print EDIT: |
Can you share the modified regex that worked for you? Your suggestion shouldn't as the last -/^force:\/\/([a-zA-Z0-9._-]+={0,2}):([a-zA-Z0-9._-]*={0,2}):([a-zA-Z0-9._-]+={0,2})@([a-zA-Z0-9._-]+)/
+/^force:\/\/([a-zA-Z0-9._-]+={0,2}):([a-zA-Z0-9._-]*={0,2}):([a-zA-Z0-9._-]+={0,2})@([a-zA-Z0-9._-]+) |
Hi @cristiand391 - Remove the first |
@gsbasso - I'm not opposed to changing this but without a way to reproduce it we can't add a unit test to know what it's fixing. Please provide either an authFile.txt that reproduces it or the contents of that file. It doesn't have to contain the exact tokens or instance url; remove or replace any characters you want. We just need it to fail with the current code and succeed with the updated code. |
The URL
but returns
|
In a browser console (to use basic js)
|
fwiw, I used Node.js v20.11.0 with both |
@mshanemc I assumed Also, the second expression is not as I had specified. You need to remove the first and last That said, I found that both returned a result (i.e. matched) when run in the Chrome console on Windows 10. But of course, this does not run in a browser. I actually tried the original expression in Apex and it did not match, while my revised version did. I see that @shetzel tested both expressions in version Anyways, all I know is I had to change the expression to get the |
@gsbasso - Is the sfdx url within your authFile.txt surrounded with quotes? If so, that could be the problem. I see this error when I surround the url with quotes in the file. However, it fails for both regex versions. |
No quotes. |
Learn how to debug a node package. I share some steps that could help you. Add some good breakpoints in the auth package, start the debugger, debug and later post your results here. steps:
Steps 6, 7 e 8 can be done using chrome instead of vscode, if you prefer.
String.prototype.match spec also works with strings. It automatically converts the given escaped string into new RegExp. |
seems valid without a browser, too. I think the "apex regex didn't like it" isn't related. Got any other clues?
|
Considering the regex states that the giving string must start with the word |
@gsbasso we just got another one (see link right above this one). There's a suggested workaround there (setting the property in a json file instead of plain text) that I'd be interested in seeing if it helps. I think this might be related to whitespace in the file perhaps. If so, we could try trimming it to get rid of whitespace, or adjusting the regex to handle whitespace better |
After restoring the original expression in Also, I realize the behaviour in Apex is not relevant but I only mentioned it earlier because it reinforced my original theory that the expression was flawed. More specifically, the code snippet below will pass if run in the developer console. The first pattern does not produce a match while the second does.
In any case I would suggest marking this as closed for now unless someone else encounters a similar issue. |
Closing per above comment. Feel free to reopen should more details be discovered. |
I'm getting this error now in the SF-supplied docker image. When I try the root@4421097c5aa1:/# sf version --verbose Architecture: Node Version: Plugin Version: OS and Version: Shell: Root Path: |
Summary
The auth URL I am using does not appear to match the format specified in the error message (see below). Specifically, the URL has the following form:
I don't know if the content in
<blah>
is actually the refreshToken, but there appears to be no value for clientSecret.Steps To Reproduce
sfdx org:login:sfdx-url --alias myAlias --sfdx-url-file <path>\authFile.txt
Expected result
Command succeeds and specified alias is authorized
Actual result
Command fails with the following error:
System Information
Additional information
I also tried the older
force:auth:sfdxurl:store
command but the result was the same.The text was updated successfully, but these errors were encountered: