Skip to content

fix(project): validate billingReference for standalone public projects#1456

Open
eloiberlinger1 wants to merge 3 commits into
stackitcloud:mainfrom
eloiberlinger1:fix-project-public-validation
Open

fix(project): validate billingReference for standalone public projects#1456
eloiberlinger1 wants to merge 3 commits into
stackitcloud:mainfrom
eloiberlinger1:fix-project-public-validation

Conversation

@eloiberlinger1

Copy link
Copy Markdown

Description

relates to #1452

Before the fix:

 ~/Documents/dev/stackit-cli  main ?1                                                                                                                                          3s

> ./stackit-test project create --parent-id 12345 --name "Test public project" --label scope=PUBLIC

Are you sure you want to create a project under the parent with ID "12345"? [y/N] y
Error: create project: 404 Not Found, status code 404, Body: {"timeStamp":"2026-07-05T19:52:13.783789128Z","path":"/resource-management/v2/projects","status":404,"error":"Not Found","message":"Container [12345] was not found."}

After the fix:

 ~/Documents/dev/stackit-cli  fix-project-public-validation ?1                                                                                                                

> ./stackit-test project create --parent-id 12345 --name "Test public project" --label scope=PUBLIC

Error: the provided flag --label is invalid: creating a standalone public project (without a network area) requires a 'billingReference' label (e.g., --label billingReference=<value>)

> 

Note on Testing

Unfortunately because I only have a French phone number, I was unable to complete the project creation process to access the STACKIT Portal to check the payload validation conditions.

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see e.g. here)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

Copilot AI review requested due to automatic review settings July 5, 2026 20:02
@eloiberlinger1 eloiberlinger1 requested a review from a team as a code owner July 5, 2026 20:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds client-side validation to stackit project create so that creating a standalone PUBLIC project (i.e., without a Network Area) fails early with a clear error when the required billingReference label is missing, aligning CLI behavior with the governance requirements described in #1452.

Changes:

  • Parse --network-area-id early during input parsing to support conditional label validation.
  • Add validation: if scope=PUBLIC and no network area is provided, require a billingReference label.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +137 to +146
if scope, hasScope := (*labels)["scope"]; hasScope && scope == "PUBLIC" {
_, hasBilling := (*labels)["billingReference"]

if networkAreaId == nil && !hasBilling {
return nil, &errors.FlagValidationError{
Flag: labelFlag,
Details: "creating a standalone public project (without a network area) requires a 'billingReference' label (e.g., --label billingReference=<value>)",
}
}
}
Comment on lines +137 to +146
if scope, hasScope := (*labels)["scope"]; hasScope && scope == "PUBLIC" {
_, hasBilling := (*labels)["billingReference"]

if networkAreaId == nil && !hasBilling {
return nil, &errors.FlagValidationError{
Flag: labelFlag,
Details: "creating a standalone public project (without a network area) requires a 'billingReference' label (e.g., --label billingReference=<value>)",
}
}
}
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

Successfully merging this pull request may close these issues.

2 participants