{"record":{"id":"9c34c6a9a9d9a2eb","repo":"ComposioHQ/composio","slug":"badencoding","errorCode":"BadEncoding","errorMessage":"BadEncoding","messagePattern":"BadEncoding","errorType":"error_code","errorClass":"KeyringError","httpStatus":null,"severity":"error","filePath":"ts/packages/cli-keyring/src/core/entry.ts","lineNumber":84,"sourceCode":"   * Store `password` as UTF-8 bytes under this entry's specifier.\n   * Overwrites any existing value.\n   */\n  async setPassword(password: string): Promise<void> {\n    await this.setSecret(textEncoder.encode(password));\n  }\n\n  /**\n   * Fetch the stored value and decode it as UTF-8. Throws\n   * `KeyringError({ kind: 'NoEntry' })` if nothing was stored, or\n   * `KeyringError({ kind: 'BadEncoding', bytes })` if the stored bytes\n   * aren't valid UTF-8 — matching keyring-rs's `Error::BadEncoding`.\n   */\n  async getPassword(): Promise<string> {\n    const bytes = await this.getSecret();\n    try {\n      return textDecoder.decode(bytes);\n    } catch {\n      throw new KeyringError({ kind: 'BadEncoding', bytes });\n    }\n  }\n\n  /** Store raw bytes. */\n  async setSecret(secret: Uint8Array): Promise<void> {\n    await this.resolveStore().setSecret(this.service, this.user, secret, this.modifiers);\n  }\n\n  /** Fetch raw bytes. Throws `NoEntry` if nothing matches. */\n  async getSecret(): Promise<Uint8Array> {\n    return this.resolveStore().getSecret(this.service, this.user, this.modifiers);\n  }\n\n  /** Delete the credential. Throws `NoEntry` if it didn't exist. */\n  async deleteCredential(): Promise<void> {\n    await this.resolveStore().deleteCredential(this.service, this.user, this.modifiers);\n  }\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/cli-keyring/src/core/entry.ts#L66-L102","documentation":"Entry.getPassword() failed to UTF-8 decode the stored secret bytes. The credential was stored as opaque binary (via setSecret) and is not valid UTF-8 text, so decoding it as a password string raises KeyringError kind 'BadEncoding'.","triggerScenarios":"Calling getPassword() on an entry whose secret was written with setSecret(binaryUint8) containing non-UTF-8 bytes.","commonSituations":"Mixing binary secret storage (tokens, keys) with the string-oriented getPassword API; corrupted keychain entries.","solutions":["Use getSecret() to read raw bytes instead of getPassword() when the value is binary","Store text via setPassword() if a string is expected later","Delete and re-store the entry if it is corrupted"],"exampleFix":"// before\nconst pw = await entry.getPassword();\n// after\nconst bytes = await entry.getSecret(); // handle as binary","handlingStrategy":"type-guard","validationCode":"// Prefer bytes API when value may be binary\nconst bytes = await entry.getSecret();","typeGuard":null,"tryCatchPattern":"catch (e) { if (e instanceof KeyringError && e.kind === 'BadEncoding') { return await entry.getSecret(); } throw e; }","preventionTips":["Use setSecret/getSecret for binary credentials","Use setPassword only for true text values"],"tags":["keyring","encoding","typescript"],"backgroundTag":"invalid-utf8-decode","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}