Skip to content

fix(scripts): resolve projects per identity in project-resource-graph.sh - #20

Merged
mauritzuph merged 1 commit into
stackitcloud:mainfrom
devpie:fix/project-resource-graph-key-scoped-projects
Sep 9, 2026
Merged

mauritzuph merged 1 commit into
stackitcloud:mainfrom
devpie:fix/project-resource-graph-key-scoped-projects

Conversation

@devpie

@devpie devpie commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

project-resource-graph.sh resolved the project independently of the identity it ran as.

  1. A run with --key still took the project from the CLI configuration. That project belongs to the logged-in session; the key is another subject and usually sits in another organization, so every service answered 403 and the run produced a table of unavailable rows. load_cli_defaults ran before resolve_identity and used the bare stackit, so the default profile always won.
  2. --all-projects did not help such a key either. stackit project list returns the projects the subject is a member of, and a role on an organization creates no membership. A service account with an organization role got an empty list and the run died with no readable projects, although the same key can read the projects of its organization.

The two defects compound: fixing only the first would leave a key with an organization role without any working way to select a project.

Change

  • The project is read from the CLI configuration only when no --key is given. The region is still inherited, because every subject uses the same regions while a project belongs to one. A key run without --project-id or --all-projects stops and says why.
  • --all-projects now takes the union of both sources, each project once: stackit project list for the memberships, plus stackit project list --parent-id <organization> for every organization of stackit organization list. An info line names the resulting count, since the meaning of the option widened.
  • --help and scripts/README.md describe both rules, including the remaining gap.

Limitation

A project inside a folder is covered by the membership list only. GET /v2/projects returns the projects that are children of the container it is asked for (resource-manager.json), and the CLI 0.72.0 has no command that lists folders. Walking the tree would need stackit curl against a hardcoded endpoint that resource_manager_custom_endpoint can override, so it is left out. Closed in a follow-up.

Tests

Run against a service account key whose role sits on an organization, region eu01:

Case Result
--key <org key> without a project stops with the new message
--key <org key> --all-projects --services network 6 projects, 2 readable, 4 reported as unavailable: ... 403
no --key, profile with project_id takes the configured project as before
no --key, profile without project_id previous message with the stackit config set hint
--all-projects --delete network/<name> --delete needs exactly one project, 6 are selected, before any query or prompt

shellcheck and bash -n are clean, prettier@3.1.0 changes nothing in scripts/README.md, check_readme_tags.py passes and generate_agents_md.py produces no diff.

🤖 Generated with Claude Code

A run with --key took the project from the CLI configuration, which belongs
to the logged-in session. The key is another subject and usually sits in
another organization, so every service answered 403. The configuration is now
read for the project only when no --key is given. A key run without
--project-id or --all-projects stops and says why.

--all-projects missed the projects of such a key too. "stackit project list"
returns the projects the subject is a member of, and a role on an
organization creates no membership there. The script now also runs "stackit
project list --parent-id" for every organization of "stackit organization
list" and takes the union, each project once. A project inside a folder is
still covered only by the membership list, because the API returns the
children of the container it is asked for and the CLI has no folder command.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mauritzuph

Copy link
Copy Markdown
Collaborator

Ty!

@mauritzuph
mauritzuph merged commit 74c69c1 into stackitcloud:main Sep 9, 2026
5 checks passed
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