equinor / equinor/fusion-framework
Throw when MsalProvider.acquireToken is called with empty scopes and no default scope
- Dominant language
- TypeScript
- Stars
- 10
- Forks
- 10
- Avg merge
- 19h 40m
- Merged PRs (30d)
- 150
Description
## Context
In `packages/modules/msal/src/MsalProvider.ts`, `acquireToken` currently only tracks a telemetry exception when the caller provides empty scopes and no client-id-derived default scope is available. It does not throw, to allow monitoring how often this happens in production before enforcing validation.
```ts
// Handle empty scopes - currently monitoring for telemetry, will throw in future
if (candidateScopes.length === 0) {
if (defaultScopes.length > 0) {
// ...
} else {
const exception = new Error(
'Empty scopes provided and clientId is missing for default scope',
);
this._trackException('acquireToken.missing-scope', TelemetryLevel.Warning, {
exception,
properties: telemetryProperties,
});
// TODO: throw exception when sufficient metrics are collected
}
}
```
## Task
Once enough telemetry data has been collected on how often this occurs in the wild, change this branch to `throw exception;` instead of only tracking it, and update the method's TSDoc `@throws` accordingly.
Contributor guide
Research direction
Open packages/modules/msal/src/MsalProvider.ts and inspect acquireToken plus its method TSDoc. Confirm that the empty-scopes branch is ready to enforce validation, then update the documented @throws behavior and verify that the branch throws the tracked exception once the telemetry decision has been made.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- authentication
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100