Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RepositoryFiles.showRaw defines return type as Blob but returns string #2276

Closed
WiseBird opened this issue Dec 13, 2021 · 3 comments · Fixed by #2258
Closed

RepositoryFiles.showRaw defines return type as Blob but returns string #2276

WiseBird opened this issue Dec 13, 2021 · 3 comments · Fixed by #2258
Labels
released This issue/pull request has been released.

Comments

@WiseBird
Copy link

showRaw method is defined as follows:

export declare class RepositoryFiles<C extends boolean = false> extends BaseResource<C> {
    ...
    showRaw(projectId: string | number, filePath: string, options?: BaseRequestOptions): Promise<Blob>;
}

But as far as I can see in reality it returns string instead of Blob:

image

Is it a wrong typing or I miss something?

@WiseBird WiseBird added the bug label Dec 13, 2021
@jdalrymple
Copy link
Owner

Sounds like i messed up the return type haha The processor in the backend encodes the response based on the content type. So even though its 'raw' (which is why its typed as a Blob), it could return a string, json or a blob. This is definitely a bug. Ill have to think of a way to enforce the return format.

Normally this isnt an issue because the return types are constant and consistent for each endpoint. This would be an exception.

@jdalrymple
Copy link
Owner

Update: it will return blob, the user will need to determine how they want to handle the blobbed response, either converting to string via .toString(), or writing to a file, in the case its an array buffer for example

@jdalrymple
Copy link
Owner

🚀 Issue was released in 37.0.0 🚀

@jdalrymple jdalrymple added the released This issue/pull request has been released. label Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants