Skip to content

Commit

Permalink
fix: 🐛 improve header order and curl formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Nov 17, 2024
1 parent 53001bc commit 6aea03b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ export function traceFetchPost(
? "Bearer ***" // Mask Bearer tokens
: "***") // Mask other authorization headers
)
const cmd = `curl ${url} \\
const cmd = `curl "${url}" \\

Check failure on line 166 in packages/core/src/fetch.ts

View workflow job for this annotation

GitHub Actions / build

The `curl` command is missing quotes around the URL, which could lead to issues if the URL contains special characters.
--no-buffer \\
${Object.entries(headers)
.map(([k, v]) => `-H "${k}: ${v}"`)
.join("\\\n")} \\
.join(" \\\n")} \\
-d '${JSON.stringify(body, null, 2).replace(/'/g, "'\\''")}'
--no-buffer
`
if (trace) trace.detailsFenced(`✉️ fetch`, cmd, "bash")
else logVerbose(cmd)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ export const OpenAIChatCompletion: ChatCompletionHandler = async (
trace.dispatchChange()

const fetchHeaders: HeadersInit = {
...getConfigHeaders(cfg),
"Content-Type": "application/json",
...getConfigHeaders(cfg),
...(headers || {}),
}
traceFetchPost(trace, url, fetchHeaders as any, postReq)
Expand Down

0 comments on commit 6aea03b

Please sign in to comment.