Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions libs/filer/workspace_files_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ func (w *WorkspaceFilesClient) Write(ctx context.Context, name string, reader io
return fileAlreadyExistsError{absPath}
}

// This API returns 400 if the file already exists, when the object type is notebook
regex := regexp.MustCompile(`Path \((.*)\) already exists.`)
// This API returns 400 if the file already exists, when the object type is notebook.
// The error_code field is empty in the JSON body, so we anchor on the
// RESOURCE_ALREADY_EXISTS marker that the API embeds in the message instead.
regex := regexp.MustCompile(`RESOURCE_ALREADY_EXISTS: (\S+)`)
if aerr.StatusCode == http.StatusBadRequest && regex.MatchString(aerr.Message) {
// Parse file path from regex capture group
matches := regex.FindStringSubmatch(aerr.Message)
Expand Down
Loading