Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): show the scope-audience warning for an empty advertised scope (BR1-L8)
Diego Zacarias693a711bf948
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex dc6ca4725..036617853 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.809",+ "version": "0.1.810","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.809",+ "version": "0.1.810","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",diff --git a/control-api/package.json b/control-api/package.jsonindex ae2438d4f..63b5beb3b 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.809",+ "version": "0.1.810","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/test/fixtures/remoteOAuthDiscovery.ts b/control-api/test/fixtures/remoteOAuthDiscovery.tsindex b4eed2db3..91c4f1a2f 100644--- a/control-api/test/fixtures/remoteOAuthDiscovery.ts+++ b/control-api/test/fixtures/remoteOAuthDiscovery.ts@@ -395,6 +395,11 @@ export const ENTRA_SHAREPOINT_SCOPE_PILOT = workIqPilotWithPrm('entra-sharepointprm.scopes_supported = ['00000003-0000-0ff1-ce00-000000000000/AllSites.Read']})+/** `scopes_supported` → an empty scope beside Work IQ's own: the empty one alone breaks the audience rule. */+export const ENTRA_EMPTY_SCOPE_PILOT = workIqPilotWithPrm('entra-empty-scope', prm => {+ prm.scopes_supported = ['', 'fdcc1f02-fc51-4226-8753-f668596af7f7/WorkIQAgent.Ask']+})+/** `scopes_supported` removed: the requested scopes fall back to the AS's OIDC-only list. */export const ENTRA_NO_SCOPES_PILOT = workIqPilotWithPrm('entra-no-scopes', prm => {delete prm.scopes_supporteddiff --git a/control-api/test/fixtures/wire/remoteMcp.discover.entraEmptyScope.json b/control-api/test/fixtures/wire/remoteMcp.discover.entraEmptyScope.jsonnew file mode 100644index 000000000..7e67d015d--- /dev/null+++ b/control-api/test/fixtures/wire/remoteMcp.discover.entraEmptyScope.json@@ -0,0 +1,36 @@+{+ "status": 200,+ "body": {+ "transport": {+ "status": "alive",+ "probedUrl": "https://workiq.svc.cloud.microsoft/mcp",+ "httpStatus": 401,+ "challenge": true+ },+ "callback": {+ "configured": true,+ "variant": "per-server",+ "redirectUriTemplate": "https://control.example.com/api/v1/oauth-callback/remote/{serverName}"+ },+ "detected": {+ "registrationMode": "manual",+ "endpoints": {+ "authorization": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/authorize",+ "token": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token"+ },+ "resource": "https://workiq.svc.cloud.microsoft/mcp",+ "issuer": "https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0",+ "asProfile": "entra-v2",+ "scopeAudienceViolation": "",+ "asEndpointHosts": {+ "authorization": "login.microsoftonline.com",+ "token": "login.microsoftonline.com"+ },+ "scopes": ["", "fdcc1f02-fc51-4226-8753-f668596af7f7/WorkIQAgent.Ask", "offline_access"],+ "quirks": {+ "bearerInBody": false,+ "supportsRefresh": true+ }+ }+ }+}diff --git a/control-api/test/routes.adminRemoteMcp.wireGoldens.test.ts b/control-api/test/routes.adminRemoteMcp.wireGoldens.test.tsindex f4c3249d5..755a571d2 100644--- a/control-api/test/routes.adminRemoteMcp.wireGoldens.test.ts+++ b/control-api/test/routes.adminRemoteMcp.wireGoldens.test.ts@@ -15,6 +15,7 @@ import {ATLASSIAN_V2_PILOT,DCR_PUBLIC_REGISTRATION_RESPONSE,DROPBOX_PILOT,+ ENTRA_EMPTY_SCOPE_PILOT,ENTRA_NO_SCOPES_PILOT,ENTRA_SHAREPOINT_SCOPE_PILOT,ENTRA_UNKNOWN_GUID_PILOT,@@ -218,6 +219,7 @@ describe('remote MCP wire goldens — POST /discover', () => {{ name: 'discover.workiq', pilot: () => ENTRA_WORKIQ_PILOT },{ name: 'discover.entraUnknownGuid', pilot: () => ENTRA_UNKNOWN_GUID_PILOT },{ name: 'discover.entraNoScopes', pilot: () => ENTRA_NO_SCOPES_PILOT },+ { name: 'discover.entraEmptyScope', pilot: () => ENTRA_EMPTY_SCOPE_PILOT },]for (const c of ENTRA_CASES) {it(`${c.name}: with the Entra tenant authority → 200`, async () => {diff --git a/control-ui/components/AddRemoteServerWizard/index.tsx b/control-ui/components/AddRemoteServerWizard/index.tsxindex 2c7ca4f44..9df4cc90c 100644--- a/control-ui/components/AddRemoteServerWizard/index.tsx+++ b/control-ui/components/AddRemoteServerWizard/index.tsx@@ -552,9 +552,12 @@ export function AddRemoteServerWizard({</div>) : null}- {detected.scopeAudienceViolation ? (+ {/* An empty advertised scope is itself the violation and arrives as `''`. */}+ {detected.scopeAudienceViolation !== undefined ? (<div className="cu-banner cu-banner--warning" role="status">- {`The server suggests the scope "${detected.scopeAudienceViolation}", which would mint a token for another API. Replace it with this server's own scope before installing.`}+ {detected.scopeAudienceViolation+ ? `The server suggests the scope "${detected.scopeAudienceViolation}", which would mint a token for another API. Replace it with this server's own scope before installing.`+ : "The server advertises an empty scope, which OAuth does not allow. It is left out of the scopes below; check they include this server's own scope before installing."}</div>) : null}diff --git a/control-ui/components/__tests__/AddRemoteServerWizard.test.tsx b/control-ui/components/__tests__/AddRemoteServerWizard.test.tsxindex a6f1396eb..94c8c23ff 100644--- a/control-ui/components/__tests__/AddRemoteServerWizard.test.tsx+++ b/control-ui/components/__tests__/AddRemoteServerWizard.test.tsx@@ -13,6 +13,7 @@ import {ATLASSIAN_DISCOVER,ATLASSIAN_DISCOVER_UNCONFIGURED,CALLBACK_UNCONFIGURED_FAILURE,+ ENTRA_EMPTY_SCOPE_DISCOVER,ENTRA_NO_SCOPES_DISCOVER,ENTRA_UNKNOWN_GUID_DISCOVER,ENTRA_UNKNOWN_TENANT_DISCOVER_FAILURE,@@ -786,6 +787,14 @@ describe('AddRemoteServerWizard', () => {)})+ it('entra 12b: an empty advertised scope still raises the audience warning', async () => {+ expect(ENTRA_EMPTY_SCOPE_DISCOVER.detected.scopeAudienceViolation).toBe('')+ await detectEntra(ENTRA_EMPTY_SCOPE_DISCOVER)+ const banner = screen.getByText(/The server advertises an empty scope/)+ expect(banner.closest('[role="status"]')).not.toBeNull()+ expect(banner).not.toHaveTextContent('""')+ })+it('entra 13: 128 scopes pass the field; the backend limit message is shown', async () => {installMock.mockRejectedValueOnce(apiErrorFrom(SCOPE_LIMIT_EXCEEDED_FAILURE))await detectEntra(WORKIQ_DISCOVER)diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 6d25e9544..b11bbefa3 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.740",+ "version": "0.1.741","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.740",+ "version": "0.1.741","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/frontend-components": "file:../packages/frontend-components",diff --git a/control-ui/package.json b/control-ui/package.jsonindex 0178f19a3..8b868dff4 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.740",+ "version": "0.1.741","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --git a/control-ui/test/fixtures/remoteMcpWire.ts b/control-ui/test/fixtures/remoteMcpWire.tsindex 663ded2c5..b7f4e7bf8 100644--- a/control-ui/test/fixtures/remoteMcpWire.ts+++ b/control-ui/test/fixtures/remoteMcpWire.ts@@ -60,6 +60,10 @@ export const ENTRA_UNKNOWN_GUID_DISCOVER = loadGolden<DiscoverRemoteResponse>(/** Work IQ whose PRM advertises no scopes: only sign-in scopes are left (scopeAudienceMissing). */export const ENTRA_NO_SCOPES_DISCOVER =loadGolden<DiscoverRemoteResponse>('discover.entraNoScopes').body+/** Work IQ whose PRM advertises an empty scope beside its own: `scopeAudienceViolation` is `''`. */+export const ENTRA_EMPTY_SCOPE_DISCOVER = loadGolden<DiscoverRemoteResponse>(+ 'discover.entraEmptyScope'+).bodyexport const ALL_DISCOVER_BODIES: ReadonlyArray<{ name: string; body: DiscoverRemoteResponse }> = [{ name: 'linear', body: LINEAR_DISCOVER },@@ -70,6 +74,7 @@ export const ALL_DISCOVER_BODIES: ReadonlyArray<{ name: string; body: DiscoverRe{ name: 'dcr-confidential', body: DCR_CONFIDENTIAL_DISCOVER },{ name: 'pre-registered-per-server', body: PRE_REGISTERED_PER_SERVER_DISCOVER },{ name: 'workiq', body: WORKIQ_DISCOVER },+ { name: 'entra-empty-scope', body: ENTRA_EMPTY_SCOPE_DISCOVER },]// ─── /discover from a control-api older than the per-server callback ─────────