ComposioHQ/composio · error · KeyringError

BadDataFormat

BadDataFormat

Error message

BadDataFormat

What it means

secret-tool returned data but decodeSecret could not parse it back into bytes (e.g. the stored value is not in the expected encoded form). KeyringError kind 'BadDataFormat' wraps the decode error along with the raw bytes.

Source

Thrown at ts/packages/cli-keyring/src/stores/linux-secret-tool.ts:195

    let result: SpawnResult;
    try {
      result = await runCommand({ command: SECRET_TOOL_BIN, args });
    } catch (err) {
      throw this.spawnErrorToKeyringError(err);
    }

    if (result.code === 0) {
      const stdout = bytesToUtf8(result.stdout);
      // `secret-tool lookup` prints the password without a trailing
      // newline when found, and prints nothing (exit 0) when not found.
      if (stdout.length === 0) {
        throw new KeyringError({ kind: 'NoEntry' });
      }
      try {
        return decodeSecret(stdout);
      } catch (err) {
        throw new KeyringError({
          kind: 'BadDataFormat',
          bytes: new Uint8Array(result.stdout),
          cause: err,
        });
      }
    }

    // Exit 1 can mean many things — stderr is the real signal.
    throw classifyFailure(result, 'secret-tool lookup');
  }

  async deleteCredential(service: string, user: string, modifiers: EntryModifiers): Promise<void> {
    validateSpecifier(service, user);
    if (missingDBus()) {
      throw new KeyringError({
        kind: 'NoStorageAccess',
        cause: new Error(
          'D-Bus session bus not available — no DBUS_SESSION_BUS_ADDRESS and no /run/user/<uid>/bus'

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Delete and re-store the credential with the current library version
  2. Confirm both writer and reader use the same library/encoding version
Defensive patterns

Strategy: try-catch

Try / catch

catch (e) { if (e instanceof KeyringError && e.kind === 'BadDataFormat') { await store.deleteCredential(service, user, mods); await reauthorize(); } else throw e; }

Prevention

When it happens

Trigger: Reading a credential that was written by another tool or an older encoding scheme, or a manually edited keyring entry.

Common situations: Version mismatches between writer and reader, interoperating with gnome-keyring entries created outside this library.

Related errors


AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28). Data as JSON: /api/errors/741f4a78787af5e2. Report an issue: GitHub.