gitbeaker icon indicating copy to clipboard operation
gitbeaker copied to clipboard

RepositoryFiles.showRaw defines return type as Blob but returns string

Open WiseBird opened this issue 3 years ago • 1 comments

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 avatar Dec 13 '21 16:12 WiseBird

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 avatar Dec 14 '21 14:12 jdalrymple

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 avatar Feb 16 '23 19:02 jdalrymple

:rocket: Issue was released in 37.0.0 :rocket:

jdalrymple avatar Apr 26 '23 17:04 jdalrymple