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
{{ message }}
Repository navigation
Commit fa18a2f
Browse filesBrowse the repository at this point in the historyBrowse files
fix(get_file_contents): Restore correct implementation from #1582
The refactor incorrectly restructured the GetFileContents logic:
- Move 'if rawOpts.SHA != "" { ref = rawOpts.SHA }' before GetContents call
- Always call GetContents first (not conditionally based on path suffix)
- Restore matchFiles helper function for proper fallback handling
- Use matchFiles when Contents API fails or raw API fails
This aligns with the improvements from PR #1582 that was merged into main.
// file content or file SHA is nil which means it's a directory
793
+
r, err:=json.Marshal(dirContent)
824
794
iferr!=nil {
825
-
returnutils.NewToolResultError(fmt.Sprintf("failed to marshal resolved refs: %s", err)), nil, nil
795
+
returnutils.NewToolResultError("failed to marshal response"), nil, nil
826
796
}
827
-
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
800
+
returnutils.NewToolResultError("failed to get file contents"), nil, nil
returnutils.NewToolResultError(fmt.Sprintf("failed to marshal matching files: %s", err)), nil, nil
1811
+
}
1812
+
resolvedRefs, err:=json.Marshal(rawOpts)
1813
+
iferr!=nil {
1814
+
returnutils.NewToolResultError(fmt.Sprintf("failed to marshal resolved refs: %s", err)), nil, nil
1815
+
}
1816
+
ifrawAPIResponseCode>0 {
1817
+
returnutils.NewToolResultText(fmt.Sprintf("Resolved potential matches in the repository tree (resolved refs: %s, matching files: %s), but the content API returned an unexpected status code %d.", string(resolvedRefs), string(matchingFilesJSON), rawAPIResponseCode)), nil, nil
1818
+
}
1819
+
returnutils.NewToolResultText(fmt.Sprintf("Resolved potential matches in the repository tree (resolved refs: %s, matching files: %s).", string(resolvedRefs), string(matchingFilesJSON))), nil, nil
1820
+
}
1821
+
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
1822
+
}
1823
+
1820
1824
// filterPaths filters the entries in a GitHub tree to find paths that
1821
1825
// match the given suffix.
1822
1826
// maxResults limits the number of results returned to first maxResults entries,
0 commit comments