Regular users get "Cannot resolve the given keypair_resource_policy key" on the legacy GQL keypair_resource_policy query
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
## Symptom
When a regular user opens the WebUI, it fails with the following GraphQL error (surfaced through the Hive gateway, `serviceName: "graphene"`):
```json
{
"message": "Bad request. (Cannot resolve the given keypair_resource_policy key)",
"path": ["keypair_resource_policy"],
"extensions": {
"code": "backendai_generic_bad-request",
"serviceName": "graphene"
}
}
```
## Reproduction
Verified on `main` at `0ff5326d2f` (26.8.0rc1-364), local halfstack dev setup, DB migrations at head (`c58b0d3a9e14`).
1. Log in as a regular user (e.g. `user@lablup.com` from `fixtures/manager/example-users.json`).
1. Run the legacy GQL query the WebUI issues:
```
{ keypair_resource_policy(name: "default") { name max_concurrent_sessions } }
```
(e.g. `./bai gql '{ keypair_resource_policy(name: "default") { name max_concurrent_sessions } }'` in session mode)
1. The query fails with the error above.
## Observations
- The `default` row exists in `keypair_resource_policies`, and the same query succeeds for a superadmin (`admin@lablup.com`), returning the policy normally.
- The regular user's own keypair references `resource_policy = 'default'`, i.e. the user is querying the policy that applies to themselves.
- Setting `[manager.rbac] enforcement-enabled = false` in `manager.toml` and restarting the manager makes the same query succeed for the regular user; re-enabling the flag brings the error back. (Used as a local workaround only.)
- Reproduced identically before and after pulling the latest `main`.
## Expected
A regular user can read the keypair resource policy that applies to their own keypair (the WebUI depends on this query during normal use).
JIRA Issue: BA-7862
Contributor guide
Research direction
Reproduce the legacy keypair_resource_policy query with ./bai gql in session mode, using the regular user from fixtures/manager/example-users.json. Read the manager RBAC behavior configured through manager.toml and compare regular-user and superadmin results, with enforcement enabled and disabled. Done means a regular user can read the policy referenced by their own keypair and the WebUI query succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, python
- Domain
- api, authorization, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100