Repository navigation
Description
Bug: SCIM answers a filter it cannot evaluate with an empty list instead of 400 invalidFilter
P2. Locally reproduced at current main 4e3c8e40fe05706a5e8796bb30b024b58c1038f9 by the TALE-223 coordinator, with an independent read-only review.
Reproduction and result
Call the SCIM collection dispatchers that services/platform/backend/domains/scim/routes.ts:116 and :118 mount (scimUsersImpl, scimGroupsImpl) with a stubbed data layer and any filter other than userName eq "…" (Users) or displayName eq "…" (Groups):
| Request | Answer on main | Expected |
|---|---|---|
GET /scim/v2/Users?filter=externalId eq "abc-123" |
200, totalResults: 0, Resources: [] |
400, scimType: invalidFilter |
GET /scim/v2/Users?filter=userName co "ada" |
200, empty list |
400, invalidFilter |
GET /scim/v2/Groups?filter=externalId eq "grp-1" |
200, empty list |
400, invalidFilter |
GET /scim/v2/Groups?filter=displayName sw "Fin" |
200, empty list |
400, invalidFilter |
The service did not evaluate these filters (no lookup ran), yet it told the identity provider that no user or group matches. A provider that matches accounts on another attribute or operator would conclude that an existing member or team is missing and try to create it again. This was not observed with a real provider. If the user name or primary email, or the group's display name, that it sends already exists in the organization, the create is refused with 409 uniqueness (backend/core/scim/http_actions.ts:104-110, :279-289). The administrator then sees a conflict instead of "this filter is not supported". If that value changed at the provider, the create can succeed and leave a second member or team. The discovery document advertises filter: { supported: true, maxResults: 200 } (backend/core/scim/discovery.ts:25) with no hint that only two eq filters work.
Root
services/platform/backend/core/scim/http_actions.ts:66-72 (Users) and :246-252 (Groups): when parseEqFilter returns null, the handler logs [scim] unsupported … filter and returns scimListResponse([], 0, 1, 0).
The narrow subset itself is deliberate: backend/core/scim/mappers.ts:4-8 ("the … eq "…" filter subset"), the parseEqFilter comment at mappers.ts:100-104 and the comment at discovery.ts:24. No comment, test or spec says that every other filter answers an empty list.
Contract, RFC 7644 §3.4.2.2: "Providers MUST decline to filter results if the specified filter operation is not recognized and return an HTTP 400 error with a "scimType" error of "invalidFilter"". §3.12 (Table 9) applies invalidFilter also when "the specified attribute and filter comparison combination is not supported".
Evidence and controls
The probe below ran in an admitted, bounded check under Node vitest (server project, one worker, no database). The four cases above fail. The control (userName eq "[email protected]") performs the lookup and answers 200.
Probe (uncommitted test beside backend/core/scim/http_actions.ts)
import { describe, expect, it, vi } from 'vitest';
import { scimGroupsImpl, scimUsersImpl, type ScimRc } from './http_actions';
function stubRc() {
const runQuery = vi.fn(async () => null);
const ctx = { runQuery, runMutation: vi.fn(async () => 'not-found'), runAction: vi.fn() };
const rc = { ctx: ctx as never, organizationId: 'org_1', defaultRole: 'member' } as ScimRc;
return { rc, runQuery };
}
async function list(coll: 'Users' | 'Groups', filter: string) {
const { rc, runQuery } = stubRc();
const impl = coll === 'Users' ? scimUsersImpl : scimGroupsImpl;
const res = await impl(rc, new Request(`https://tale.example/scim/v2/${coll}?filter=${encodeURIComponent(filter)}`));
return { status: res.status, body: (await res.json()) as Record<string, unknown>, queried: runQuery.mock.calls.length };
}
describe('SCIM filters the service cannot evaluate', () => {
it.each([
['Users', 'externalId eq "abc-123"'],
['Users', 'userName co "ada"'],
['Groups', 'externalId eq "grp-1"'],
['Groups', 'displayName sw "Fin"'],
] as const)('%s?filter=%s is declined with 400 invalidFilter', async (coll, filter) => {
const r = await list(coll, filter);
expect({ status: r.status, scimType: r.body.scimType }).toEqual({ status: 400, scimType: 'invalidFilter' });
});
it('control: a supported userName eq filter runs the lookup and answers 200', async () => {
const r = await list('Users', 'userName eq "[email protected]"');
expect(r.status).toBe(200);
expect(r.queried).toBe(1);
});
});Deduplication and acceptance
All 1,385 issues were searched for SCIM, filter and invalidFilter. #1921, #2036, #2085 and #2116 cover SCIM provisioning, cross-tenant grafting and a PATCH clear-all edge, but none covers how filters are answered. The SCIM domain spec lists "Listing, paging and filtering" under Not yet. That means no rule states the current behaviour; it is not recorded debt.
Acceptance:
- A filter whose attribute or operator the service does not evaluate answers
400withscimType: invalidFilterand a readabledetail, on both collections. userName eqanddisplayName eqkeep working.- If more attributes are supported later (for example
externalId eq), they answer real matches.
Limits: the dispatchers ran with a stubbed ctx (as in http_actions.test.ts). No real identity provider, PostgreSQL or HTTP stack was exercised.
Activity
fix(platform): answer unsupported SCIM filters with invalidFilter
fix(platform): answer unsupported SCIM filters with invalidFilter