Skip to content

Trim whitespace from printhost API keys to avoid Prusa-Link HTTP 415 error#15448

Open
BasPaap wants to merge 1 commit into
prusa3d:masterfrom
BasPaap:sanitize-api-key
Open

Trim whitespace from printhost API keys to avoid Prusa-Link HTTP 415 error#15448
BasPaap wants to merge 1 commit into
prusa3d:masterfrom
BasPaap:sanitize-api-key

Conversation

@BasPaap

@BasPaap BasPaap commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Trim leading/trailing whitespace from printhost_apikey when loading, editing, and saving Physical Printer settings
  • Trim API key in OctoPrint constructor before sending X-Api-Key headers (affects PrusaLink uploads)

Problem

Copying the Prusa-Link API key into PrusaSlicer can include invisible trailing newline characters. Uploads then fail with a misleading HTTP 415: Only G-Code for FDM printer can be uploaded even though the G-code is valid. The web UI works because it uses digest auth instead of the API key.

Related

Complements prusa3d/Prusa-Link#1047 (server-side API key sanitization).

Test plan

  • Paste an API key with trailing newlines into Physical Printer settings; confirm they are stripped from the field
  • Upload to Prusa-Link via Send to printer succeeds with a pasted key that previously failed
  • Existing printers with clean API keys still upload normally

…ilures.

Pasted API keys can include trailing newlines that break X-Api-Key headers
and cause misleading HTTP 415 errors from Prusa-Link.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants