Skip to content

[BUG]: Cache type for get should allow null or undefined #716

@Meierschlumpf

Description

@Meierschlumpf

What happened?

It's currently not possible to use a custom cache that returns no value, because there might be no value yet stored for the key. The return type is expected to be string.

Current type:

export type Cache = Lru<string> | {
    get: (key: string) => string | Promise<string>;
    set: (key: string, value: string) => any;
};

Simple cache implementation with map:

const cache = new Map<string, string>();

const result = createAppAuth({
      appId,
      privateKey,
      installationId,
      cache: {
        get(key: string) {
          // This causes a type error, even if the current implementation just checks for the cache with cache.get(key) and then checking if with if(!cache) return
          return cache.get(key);
        },
        set(key: string, value: string) {
          cache.set(key, value);
        },
      }
})

Versions

  • octokit 5.0.3
  • @octokit/auth-app 8.1.0
  • NodeJS v22.15.1

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageThis is being looked at and prioritizedType: BugSomething isn't working as documented, or is being fixed

    Type

    No type

    Projects

    Status

    🆕 Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions