@databricks/sdk-experimental (pinned by AppKit): SCIM v2 list() iterators never advance startIndex and never terminate

Ouverte
#656 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 3 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
Une demi-journée
Accessibilité débutants
42/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
javascript, typescript
Domaine
api

Piste de recherche

The bug is in the shipped dist/apis/iam/api.js of @databricks/sdk-experimental, in the async *list generators of the six SCIM V2 services (for example ServicePrincipalsV2Service). Read that loop first: request never changes, so startIndex never advances. Done means each generator adds the page length to startIndex and stops on an empty page, verified with a mocked SCIM response. The source likely lives in the upstream SDK repo, not this one, so confirm where to make the change first.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Summary

The six SCIM v2 list() async iterators in @databricks/sdk-experimental request the same page on every pass. When the result is not empty they yield the first page again and again and never finish.

AppKit pins @databricks/sdk-experimental 0.17.0 and gives apps its WorkspaceClient, so an AppKit app that iterates users, groups or service principals this way hangs and keeps calling the SCIM API.

I am filing this here because the SDK's own tracker (the bugs.url in its package.json, github.com/databricks/databricks-sdk-js/issues) is not publicly reachable. Please move it if there is a better place.

Affected
  • @databricks/sdk-experimental 0.17.0 and 0.18.0 (the latest), in dist/apis/iam/api.js.
  • Workspace client: usersV2.list, groupsV2.list, servicePrincipalsV2.list.
  • Account client: accountUsersV2.list, accountGroupsV2.list, accountServicePrincipalsV2.list.

I checked every async iterator in 0.18.0 (127): these six are the only ones that loop on an unchanged request.

Code as shipped (0.18.0, ServicePrincipalsV2Service)
async *list(request, context) {
    while (true) {
        const response = await this._list(request, context);
        if (context?.cancellationToken &&
            context?.cancellationToken.isCancellationRequested) {
            break;
        }
        if (!response.Resources || response.Resources.length === 0) {
            break;
        }
        for (const v of response.Resources) {
            yield v;
        }
    }
}

request is never changed, so startIndex stays where the caller set it. The loop ends only on an empty page, and a first page that has items never becomes empty.

Reproduce

On any workspace that has at least one service principal:

import {WorkspaceClient} from "@databricks/sdk-experimental";

const w = new WorkspaceClient({});
let n = 0;
for await (const sp of w.servicePrincipalsV2.list({})) {
  n++;
  if (n > 10_000) throw new Error("still iterating"); // always reached
}

The same items come back in the same order on every pass.

Expected

After each page, add the number of items returned to startIndex and stop on an empty page. The modular SDK already does this in databricks/sdk-js, packages/scim/src/v1/client.ts:

pageReq.startIndex = (resp.startIndex ?? 0n) + BigInt(items.length);
Workaround

Page explicitly: call the SCIM list endpoint with startIndex and count, and add each page's length to startIndex until a page comes back empty.

Langage dominant
TypeScript
Étoiles
119
Forks
36
Merge moyen
4 j 16 h
PR mergées (30 j)
37

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de databricks/appkit

Toutes les issues de databricks/appkit

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.