-
Notifications
You must be signed in to change notification settings - Fork 366
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: honor --auth option #6838
base: main
Are you sure you want to change the base?
fix: honor --auth option #6838
Conversation
067e6ae
to
4fcd76d
Compare
ec0f91a
to
e64e30c
Compare
@@ -382,7 +382,7 @@ const uploadDeployBlobs = async ({ | |||
packagePath, | |||
deployId, | |||
siteId, | |||
token, | |||
token: token === null ? undefined : token, |
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.
token
here is of type string | null
, while runCoreSteps
expect it to be string | undefined
Overall at this stage there should be a token always, otherwise we would bail much earlier, but stuff like this is annoying with TS and probably would need more refactoring to not have to deal with null / undefined
cases.
src/commands/integration/deploy.ts
Outdated
@@ -394,8 +394,7 @@ export const getConfiguration = (workingDir) => { | |||
export const deploy = async (options: OptionValues, command: BaseCommand) => { | |||
const { api, cachedConfig, site, siteInfo } = command.netlify | |||
const { id: siteId } = site | |||
// @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. | |||
const [token] = await getToken() | |||
const [token] = await command.authenticate(options.auth) |
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.
Note that this one will have a potential change in behavior - by using command.authenticate
(like almost all the other commands, except for status
, login
, logout
and build
) - this will start auth flow if user is not logged in (or didn't provide token via env var or --auth
), while previously it would result in getting no token (and presumably getting failures later down the road?)
After fixing up bunch of related TypeScript elsewhere, using the getToken
that could be null
(previously it would be just any
) it would complain about token
being possibly null
in
cli/src/commands/integration/deploy.ts
Lines 421 to 428 in e64e30c
const { body: registeredIntegration, statusCode } = await fetch( | |
`${getIntegrationAPIUrl()}/${accountId}/integrations?site_id=${siteId}`, | |
{ | |
headers: { | |
'netlify-token': token, | |
}, | |
}, | |
).then(async (res) => { |
so I assume this should be required that token is present before executing the rest of this command?
cc @netlify/ecosystem-pod-composable-tooling
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
@@ -953,6 +954,71 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co | |||
}) | |||
}) | |||
|
|||
test('should upload blobs when saved into .netlify directory and using --auth flag', async (t) => { |
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 test alone was failing (at least in GHA) without code changes done in 2nd commit
e64e30c
to
a39900b
Compare
@pieh is this something we want to get over the finish line? |
🎉 Thanks for submitting a pull request! 🎉
Summary
Fixes https://linear.app/netlify/issue/FRB-1343/internal-server-error-on-netlify-builds-via-bitbucket-pipeline-missing
Our
--auth
CLI option handling seems a bit hit and miss. We had a lot of optional argument and@ts-expect-error
around code that was dealing with tokens - this removes all of those, adjust types to require token from CLI toggle being passed in to helper functions (do note that this doesn't fully ensure type safety, becauseoptions.auth
has typeany
, but at least it ensures that something is passed in instead of being optional)For us to review and ship your PR efficiently, please perform the following steps:
passes our tests.
A picture of a cute animal (not mandatory, but encouraged)