vercel-azure-devops-extension
vercel-azure-devops-extension copied to clipboard
Non-production deployments causing task to fail
Vercel deployments are succeeding to non-prod (production: false), but Azure is reporting task failure:
To deploy to production (mywebsite.com), run `vercel --prod`
##[error]Cannot read properties of undefined (reading 'length')
Finishing: verceldeploymenttask
Only difference between the below YAML examples is the production input.
Successful YAML (deployment and Azure task succeed):
trigger:
branches:
include:
- main
paths:
include:
- my-project
pool:
vmImage: ubuntu-latest
steps:
- task: vercel-deployment-task@1
inputs:
vercelProjectId: 'my-proj-id-here'
vercelOrgId: 'my-org-id-here'
vercelToken: '$(VERCEL_TOKEN)'
vercelCWD: 'my-project'
production: true
debug: true
Failing YAML (deployment succeeds, azure task reports failure):
trigger:
branches:
include:
- main
paths:
include:
- my-project
pool:
vmImage: ubuntu-latest
steps:
- task: vercel-deployment-task@1
inputs:
vercelProjectId: 'my-proj-id-here'
vercelOrgId: 'my-org-id-here'
vercelToken: '$(VERCEL_TOKEN)'
vercelCWD: 'my-project'
production: false
debug: true
Both of these will successfully deploy to Vercel (one to prod, another to a preview), but the deployment task is being reported as failing in Azure in the latter.
It's happening to us too, since we configured the pipeline, a month ago we tried but failed to find a workaround It isn't very pleasant because our CI/CD notification reports the successful pipeline as a failed (with red) Fingers crossed a fix is easy to implement
I'm getting a similar issue--the deploy job runs until it times out, but the Vercel preview build was fully deployed.
I encountered a similar issue where the deployment was successful on Vercel, but it failed on Azure. Changing the version as mentioned here resolved the problem for me for now. https://github.com/vercel/vercel-azure-devops-extension/issues/32#issue-2482471330
Hey all, apologies for the error, the latest version 1.6.0 should be working for you now and I'm working on adding a preview version of the extension for more thorough testing in the future!
@codybrouwers This still appears to be happening on 1.6. Just tested now, and the error message is present with the task failing:
To deploy to production (my.website.domain), run `vercel --prod`
##[error]Cannot read properties of undefined (reading 'length')
Finishing: verceldeploymenttask
Ah okay, sorry about that @general-adhoc, I assumed it was related to an issue we had to rollback for 1.6.0. I'll reopen this issue
I encountered a similar issue where the deployment was successful on Vercel, but it failed on Azure. Changing the version as mentioned here resolved the problem for me for now. #32 (comment)
@Paulshaju thank you for the workaround here 🙏
@codybrouwers Would you happen to know why an Azure DevOps pipeline would not be recognizing a specific task version?
When I attempt to pin my task at 1.3.0:
- task: [email protected]
I receive an error:
A task is missing. The pipeline references a task called 'vercel-deployment-task'. This usually indicates the task isn't installed...
I believe the reason might be that the Vercel Deployment Extension I have installed from the marketplace is set to 1.6.3?
Thank you for your help (I'm new to Azure...) and for maintaining this extension.
Is there a bypass for the users who use this in the GUI release pipelines and can't change the version as they please? or is there any solution in sight for a new version with this issue fixed?
thx
I think I've figured out the root cause!
TLDR: As a quick fix make sure to use your Team ID (starting with team_) instead of your Personal Vercel ID for the vercelOrgId input.
You can find your Team ID by navigating to Account Overview and opening the submenu for the team associated with your application, and selecting Manage.
Scroll down and you will find your Team ID:
For reference here a PR with succeeding pipeline and preview deployment.
To the actual issue:
If run with a Personal Vercel ID as vercelOrgId the extension tries to retrieve the stagingPrefix from the Vercel REST API endpoint /v2/user for the creation of your preview deployment's alias URL. The response varies depending on the token's scope:
- If the scope is set to a specific team the response will contain the object labelled
AuthUserLimitedin the docs and doesn't contain a propstagingPrefix, thus the pipeline crashes in vercel-deployment-task-source/src/index.ts:275 with the exceptionCannot read properties of undefined (reading 'length')– see this run. - If the scope is set to Full Account the response will contain the object labelled
AuthUserand actually contain thestagingPrefix, but the creation of the alias will fail because the pipeline provides thevercelOrgIdinput as scope to the Vercel CLI as well. This is not supported – see failed run here.
With a Full Account scope token you can retrieve a defaultTeamId from the /v2/user endpoint and and with some additions to the plugin we could possibly make it work, but this seems unsafe in case the account is linked to multiple teams. To add some speculation from my side: in the past Vercel didn't assign teams to single user/personal accounts. Therefore there might have been no alternative to using the Personal Vercel ID. This seems to be changed with the 'Northstar' migration and now all projects should be tied to a Team ID – I can't find any details on this but found multiple references in API schemas.
If this assumption is correct and all accounts are migrated (@codybrouwers – maybe you can confirm?) I would propose to remove support for the Personal Vercel ID altogether in favor of only allowing usage of a Team ID. I'll prepare a PR adjusting the docs to match the quick fix I've described in the beginning and prepare a second PR to remove the functionality tied to the Personal Vercel ID. As this is a breaking change (at least config-wise) I would consider to publish this version as a V2, even though production deployments should still work just fine.
Addition: This is issue not related to #32 and thus can't be avoided by pinning your version to an older version!
Adjusting Docs: #42 Deprecating usage of Personal Vercel ID: #43
Thanks @phidol - confirming your suggestion fixed for our use case!