backstage / backstage/community-plugins
rollbar: Rollbar plugin cannot authenticate with Rollbar "v2" project access tokens
- Dominant language
- TypeScript
- Stars
- 422
- Forks
- 697
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 286
Description
### Workspace
rollbar
### 📜 Description
`@backstage-community/plugin-rollbar-backend` fails to fetch items/reports for any project whose project access tokens are **Rollbar "v2" tokens**. The backend returns:
```
500 Internal Server Error
Could not find an active project read access token for ''
```
This happens even when the project **does** have an active `read`-scoped project access token, because the plugin depends on the Rollbar API returning the token's **value**, which Rollbar no longer exposes for v2 tokens.
## 🔍 Root cause
`RollbarApi.getProjectMetadata()` resolves the project token by listing the project's access tokens and reading `token.accessToken`:
```ts
const tokens = await this.getProjectAccessTokens(project.id);
const token = tokens.find(t => t.scopes.includes('read') && t.status !== 'expired');
project.accessToken = token ? token.accessToken : undefined;
if (!project.accessToken) {
throw Error(`Could not find an active project read access token for '${name}'`);
}
```
Rollbar's `GET /api/1/project/{id}/access_tokens` behaves differently depending on `token_type`:
- **legacy** tokens → the response includes `access_token` (the value).
- **v2** tokens (the only kind Rollbar creates today) → the response **omits `access_token`** entirely; the value is shown only once at creation.
Example response for the same project (account token has read+write scope):
```json
{ "name": "backstage", "status": "enabled", "scopes": ["read"], "token_type": "v2" } // no access_token field
{ "name": "read", "status": "expired", "scopes": ["read"], "token_type": "legacy",
"access_token": "ac5f4dfe...." } // value present
```
So for v2 read tokens `token.accessToken` is always `undefined`, and the plugin cannot authenticate the item/report calls. Since Rollbar no longer lets you create (or re-enable) legacy tokens, there is **no configuration workaround** — the plugin is unusable for any project created after Rollbar's move to v2 tokens.
The current `main` still has this logic unchanged.
## 💡 Proposed fix
Any of:
1. Allow supplying the project read token **value** directly (e.g. `rollbar.com/read-token` annotation, or `rollbar.projects..readToken` config), bypassing the list lookup — v2 values are known at creation time.
2. If Rollbar's item/report endpoints accept an **account** read token (with project scoping), use that instead of resolving a per-project token.
3. At minimum, fail with an actionable error explaining the v2/legacy limitation.
## 🖥️ Environment
- `@backstage-community/plugin-rollbar` `0.13.0` / `plugin-rollbar-backend` `0.12.0`
- Backstage `1.52.0`
- Reproduced against Rollbar's current API (project tokens are `token_type: v2`)
### 👍 Expected behavior
The Rollbar tab loads the project's items when the project has an active `read` project access token.
### 👎 Actual Behavior with Screenshots
`getProjectMetadata()` finds the read token but `token.accessToken` is `undefined`, so it throws `Could not find an active project read access token`.
### 👟 Reproduction steps
1. Configure `rollbar.accountToken` with a valid account token.
2. Annotate a component with `rollbar.com/project-slug: `, where `` only has **v2** project access tokens (i.e. any recently created Rollbar project).
3. Open the component's **Rollbar** tab → `500 Could not find an active project read access token`.
### 📃 Provide the context for the Bug.
_No response_
### 👀 Have you spent some time to check if this bug has been raised before?
- [x] I checked and didn't find similar issue
### 🏢 Have you read the Code of Conduct?
- [x] I have read the [Code of Conduct](https://github.com/backstage/community-plugins/blob/main/CODE_OF_CONDUCT.md)
### Are you willing to submit PR?
None
Contributor guide
Assessment
This issue has not been assessed yet.