Bot TAT is minted on every invocation (memory-only cache), causing 'TAT endpoint rate limited (HTTP 429)' for subprocess callers

Abierto
#2,863 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
42/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go

Línea de trabajo

Start with internal/credential/default_provider.go and internal/credential/tat_fetch.go, then inspect TenantTokenStore and the existing config tenant-access-token flow. Trace how tokens are resolved, stored, and rejected, and how endpoint 429 responses are mapped. Done means minted TATs can be reused securely across invocations and token endpoint throttling is distinguishable in JSON, including Retry-After when provided.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug domain/core

Summary

For bot identity, lark-cli caches the minted tenant access token (TAT) only in process memory. When it is driven as a short-lived subprocess (one process per API call, which is the normal way scripts and agents use it), every invocation therefore mints a new TAT before making the actual OpenAPI call. Under modest, steady load this throttles the token endpoint, and the API call fails with:

{"type":"api","subtype":"rate_limit","code":429,"message":"TAT endpoint rate limited (HTTP 429)"}

The underlying OpenAPI call never runs, so the failure is not a 99991400 frequency-control rejection and carries no log_id. That makes it look like an unexplained OpenAPI rate limit to the caller.

Environment

  • lark-cli v1.0.98 (also seen on v1.0.97), darwin-arm64, brand lark
  • Bot identity (--as bot), one self-built app
  • Several independent local tools invoke lark-cli for the same app, each call in a new process

Observed

  • About 3–5% of calls (reads and writes alike) fail with the error above, even at 1–2 calls per minute in total for one tool.
  • None of the failures include log_id, retry_after_seconds or a 99991400 code.
  • Downgrading from v1.0.98 to v1.0.97 did not change the rate.

Where in the code

  • internal/credential/default_provider.go: resolveTAT keeps tatResult in memory and doResolveTAT calls FetchTAT directly. The minted token is never written to or read from TenantTokenStore.
  • internal/credential/tat_fetch.go: an HTTP 429 from the token endpoint is mapped to APIError{Subtype: rate_limit, Code: 429} with the message "TAT endpoint rate limited (HTTP 429)".
  • TenantTokenStore and config tenant-access-token set together with LARKSUITE_CLI_TENANT_ACCESS_TOKEN_SOURCE=credential-store already exist, but they only cover a token supplied externally.

Request

  1. Persist minted TATs across invocations: cache them in the existing secure store until shortly before expires_in, and reuse them in later processes for the same app and account. Re-mint only on expiry, or when a call is rejected for an invalid or expired token.
  2. Make token-endpoint throttling distinguishable in the JSON error, for example a stable subtype or field such as source: "tat_endpoint", so callers can tell it apart from an OpenAPI 99991400 without parsing message text. Include retry_after_seconds when the endpoint provides Retry-After.

Related: #2860 (the accounts token endpoint returns a plain-text 429 for the user-token refresh path).

Lenguaje dominante
Go
Estrellas
18.2k
Forks
1.4k
Merge medio
1 d 3 h
PR fusionados (30 d)
18

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de larksuite/cli

Todos los issues de larksuite/cli

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.