fix: URL-encode asset filename, truncate error body in APIError
CI / test (pull_request) Successful in 14s
CI / review (gpt-4.1, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 23s
CI / review (gpt-5, security, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 51s
CI / review (gpt-5, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 1m21s
CI / test (pull_request) Successful in 14s
CI / review (gpt-4.1, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 23s
CI / review (gpt-5, security, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 51s
CI / review (gpt-5, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 1m21s
- URL-encode filename in release upload query param (MINOR) - Truncate APIError.Body to 200 chars in Error() to avoid leaking verbose server responses into logs (NIT)
This commit is contained in:
@@ -90,7 +90,7 @@ jobs:
|
|||||||
curl -sSf -X POST \
|
curl -sSf -X POST \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
-H "Content-Type: application/octet-stream" \
|
-H "Content-Type: application/octet-stream" \
|
||||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${filename}" \
|
"${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$(printf '%s' "${filename}" | jq -sRr @uri)" \
|
||||||
--data-binary "@${file}"
|
--data-binary "@${file}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -26,7 +26,11 @@ type APIError struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *APIError) Error() string {
|
func (e *APIError) Error() string {
|
||||||
return fmt.Sprintf("HTTP %d: %s", e.StatusCode, e.Body)
|
body := e.Body
|
||||||
|
if len(body) > 200 {
|
||||||
|
body = body[:200] + "...(truncated)"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("HTTP %d: %s", e.StatusCode, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNotFound reports whether an error is an API 404 response.
|
// IsNotFound reports whether an error is an API 404 response.
|
||||||
|
|||||||
Reference in New Issue
Block a user