这是indexloc提供的服务,不要输入任何密码
Skip to content

Improve error messaging for mismatching team_id/project_id #35

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

Merged
merged 2 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions vercel/resource_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,16 @@ func (r resourceDeployment) Create(ctx context.Context, req tfsdk.CreateResource
Ref: plan.Ref.Value,
}

_, err = r.p.client.GetProject(ctx, plan.ProjectID.Value, plan.TeamID.Value)
var apiErr client.APIError
if err != nil && errors.As(err, &apiErr) && apiErr.StatusCode == 404 {
resp.Diagnostics.AddError(
"Error creating deployment",
"Could not find project, please make sure both the project_id and team_id match the project and team you wish to deploy to.",
)
return
}

out, err := r.p.client.CreateDeployment(ctx, cdr, plan.TeamID.Value)
var mfErr client.MissingFilesError
if errors.As(err, &mfErr) {
Expand Down
10 changes: 10 additions & 0 deletions vercel/resource_project_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ func (r resourceProjectDomain) Create(ctx context.Context, req tfsdk.CreateResou
return
}

_, err := r.p.client.GetProject(ctx, plan.ProjectID.Value, plan.TeamID.Value)
var apiErr client.APIError
if err != nil && errors.As(err, &apiErr) && apiErr.StatusCode == 404 {
resp.Diagnostics.AddError(
"Error creating project domain",
"Could not find project, please make sure both the project_id and team_id match the project and team you wish to deploy to.",
)
return
}

out, err := r.p.client.CreateProjectDomain(ctx, plan.ProjectID.Value, plan.TeamID.Value, plan.toCreateRequest())
if err != nil {
resp.Diagnostics.AddError(
Expand Down