You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnutils.NewToolResultError(fmt.Sprintf("failed to marshal matching files: %s", err)), nil, nil
648
+
}
649
+
resolvedRefs, err:=json.Marshal(rawOpts)
650
+
iferr!=nil {
651
+
returnutils.NewToolResultError(fmt.Sprintf("failed to marshal resolved refs: %s", err)), nil, nil
652
+
}
653
+
returnutils.NewToolResultError(fmt.Sprintf("Resolved potential matches in the repository tree (resolved refs: %s, matching files: %s), but the raw content API returned an unexpected status code %d.", string(resolvedRefs), string(matchingFilesJSON), rawAPIResponseCode)), nil, nil
654
+
}
655
+
returnutils.NewToolResultError("Failed to get file contents. The path does not point to a file or directory, or the file does not exist in the repository."), nil, nil
653
656
}
654
-
deferfunc() {
655
-
_=resp.Body.Close()
656
-
}()
657
657
658
-
ifresp.StatusCode==http.StatusOK {
659
-
// If the raw content is found, return it directly
660
-
body, err:=io.ReadAll(resp.Body)
658
+
iffileContent!=nil&&fileContent.SHA!=nil {
659
+
fileSHA=*fileContent.SHA
660
+
661
+
rawClient, err:=getRawClient(ctx)
661
662
iferr!=nil {
662
-
returnutils.NewToolResultError("failed to read response body"), nil, nil
663
+
returnutils.NewToolResultError("failed to get GitHub raw content client"), nil, nil
// file content or file SHA is nil which means it's a directory
733
+
r, err:=json.Marshal(dirContent)
741
734
iferr!=nil {
742
-
returnutils.NewToolResultError(fmt.Sprintf("failed to marshal resolved refs: %s", err)), nil, nil
735
+
returnutils.NewToolResultError("failed to marshal response"), nil, nil
743
736
}
744
-
returnutils.NewToolResultError(fmt.Sprintf("Resolved potential matches in the repository tree (resolved refs: %s, matching files: %s), but the raw content API returned an unexpected status code %d.", string(resolvedRefs), string(matchingFilesJSON), rawAPIResponseCode)), nil, nil
returnutils.NewToolResultError("Failed to get file contents. The path does not point to a file or directory, or the file does not exist in the repository."), nil, nil
740
+
returnutils.NewToolResultError("failed to get file contents"), nil, nil
0 commit comments