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

Non-production deployments causing task to fail #28

Open
general-adhoc opened this issue Aug 17, 2024 · 11 comments
Open

Non-production deployments causing task to fail #28

general-adhoc opened this issue Aug 17, 2024 · 11 comments

Comments

@general-adhoc
Copy link

general-adhoc commented Aug 17, 2024

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.

@JiRadu
Copy link

JiRadu commented Aug 22, 2024

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

@elemdisc
Copy link

I'm getting a similar issue--the deploy job runs until it times out, but the Vercel preview build was fully deployed.

@Paulshaju
Copy link

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)

@codybrouwers
Copy link
Member

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!

@general-adhoc
Copy link
Author

general-adhoc commented Sep 18, 2024

@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

@codybrouwers codybrouwers reopened this Sep 19, 2024
@codybrouwers
Copy link
Member

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

@cheshireoctopus
Copy link

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:

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?

image

Thank you for your help (I'm new to Azure...) and for maintaining this extension.

@JiRadu
Copy link

JiRadu commented Oct 24, 2024

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

@phidol
Copy link
Contributor

phidol commented Nov 10, 2024

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.
image
Scroll down and you will find your Team ID:
image

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 AuthUserLimited in the docs and doesn't contain a prop stagingPrefix, thus the pipeline crashes in vercel-deployment-task-source/src/index.ts:275 with the exception Cannot read properties of undefined (reading 'length') – see this run.
  • If the scope is set to Full Account the response will contain the object labelled AuthUser and actually contain the stagingPrefix, but the creation of the alias will fail because the pipeline provides the vercelOrgId input 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.

@phidol
Copy link
Contributor

phidol commented Nov 10, 2024

Addition: This is issue not related to #32 and thus can't be avoided by pinning your version to an older version!

@phidol
Copy link
Contributor

phidol commented Nov 10, 2024

Adjusting Docs: #42
Deprecating usage of Personal Vercel ID: #43

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

No branches or pull requests

7 participants