diff --git a/gitea/client.go b/gitea/client.go index 45389a6..55835ac 100644 --- a/gitea/client.go +++ b/gitea/client.go @@ -458,6 +458,10 @@ func (c *Client) ListContents(ctx context.Context, owner, repo, path string) ([] if err2 := json.Unmarshal(body, &single); err2 != nil { return nil, fmt.Errorf("parse contents JSON: %w", err) } + // Guard against empty/malformed responses + if single.Name == "" && single.Path == "" { + return nil, fmt.Errorf("parse contents JSON: empty response for path %q", path) + } entries = []ContentEntry{single} } return entries, nil