Skip to content

Profile fetching functions (ownProfile(), profileForSlug(), etc.) fails for profile with no picture #229

@astralblue

Description

@astralblue

Describe the bug
When a profile has no profile picture, the API returns photo_url === null, and it triggers this error:

Invalid Full profile response: Invalid value null supplied to : ({ id: number, name: string, handle: string, photo_url: string } & Partial<{ bio: string }>)/0: { id: number, name: string, handle: string, photo_url: string }/photo_url: string
Uncaught:
Error: Failed to get own profile: Invalid Full profile response: Invalid value null supplied to : ({ id: number, name: string, handle: string, photo_url: string } & Partial<{ bio: string }>)/0: { id: number, name: string, handle: string, photo_url: string }/photo_url: string
    at SubstackClient.ownProfile (/.../node_modules/.pnpm/substack-api@2.2.1/node_modules/substack-api/dist/index.js:1510:19)

To Reproduce
Steps to reproduce the behavior:

  1. Create a new account and set up its profile
  2. Use the account's cookie to initialize a client
  3. await client.ownProfile()
  4. See error

Expected behavior
Return a profile with photo_url of null or '' (note: null means changing the profile definition, right now it is always a string).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions