Skip to content

Remove DigestAuthWorkaround, require Prusa firmware 5.2.0+#155

Draft
heikkih wants to merge 1 commit into
home-assistant-libs:mainfrom
heikkih:fix/remove-digest-auth-workaround
Draft

Remove DigestAuthWorkaround, require Prusa firmware 5.2.0+#155
heikkih wants to merge 1 commit into
home-assistant-libs:mainfrom
heikkih:fix/remove-digest-auth-workaround

Conversation

@heikkih
Copy link
Copy Markdown
Contributor

@heikkih heikkih commented Apr 23, 2026

Summary

Removes the DigestAuthWorkaround subclass and uses httpx.DigestAuth directly.
This is the second PR in a series of improvements to pyprusalink and the Home Assistant prusalink integration (first PR: #154).

Background

The workaround was introduced to handle two bugs:

Issue Fix released
encode/httpx#3045 — RFC 2069 Digest auth sent a malformed header httpx 0.27.0 (2024-02-21)
prusa3d/Prusa-Firmware-Buddy#3665 — firmware rejected unquoted algorithm parameter firmware 5.2.0 (2024-02-06)

Both fixes are over a year old. The firmware fix was confirmed present in v5.2.0 via commit 9123619e0b in that release's history.

Changes

  • pyprusalink/client.py: Removes DigestAuthWorkaround (and the now-unused hashlib, Request, _DigestAuthChallenge imports). ApiClient now sets self._auth = DigestAuth(...) directly.
  • pyproject.toml: Pins httpx>=0.27.0 to ensure the fixed version is always used.
  • README.md: Documents the firmware 5.2.0 minimum requirement.
  • tests/test_client.py: Replaces the two workaround behaviour tests with a single assertion that type(api._auth) is httpx.DigestAuth.

Test plan

  • pytest tests/ -v — 14 passed
  • flake8 pyprusalink tests — no errors
  • black --check pyprusalink tests — no reformats needed
  • isort --check pyprusalink tests — no changes needed

🤖 Generated with Claude Code

@heikkih heikkih force-pushed the fix/remove-digest-auth-workaround branch 2 times, most recently from f203644 to 62b41d4 Compare April 27, 2026 15:15
@agners
Copy link
Copy Markdown
Contributor

agners commented Apr 27, 2026

Removes the DigestAuthWorkaround subclass and uses httpx.DigestAuth directly.
This is the second PR in a series of improvements to pyprusalink and the Home Assistant prusalink integration (first PR: #154).

From what I know Prusa printers don't usually auto-update, so there might be users with older firmware no?

Is there any pressing need to remove this workaround?

@heikkih
Copy link
Copy Markdown
Contributor Author

heikkih commented Apr 28, 2026

Removes the DigestAuthWorkaround subclass and uses httpx.DigestAuth directly.
This is the second PR in a series of improvements to pyprusalink and the Home Assistant prusalink integration (first PR: #154).

From what I know Prusa printers don't usually auto-update, so there might be users with older firmware no?

Is there any pressing need to remove this workaround?

No real pressing need. Just wanted to clean it up and keep the code more maintainable (even if it's a small thing).

Users should really upgrade as there are so many improvements in the newer ones, so I thought this could be a nice incentive to encourage upgrading as well.

Main motive of this patch is actually to have the discussion about it with someone :)

I'm ok with leaving it out for now.

@agners
Copy link
Copy Markdown
Contributor

agners commented Apr 28, 2026

Users should really upgrade as there are so many improvements in the newer ones, so I thought this could be a nice incentive to encourage upgrading as well.

100% agree, and I just checked, mine is on 6.4.0, so quite a bit newer.

However, I guess quite some Home Assistant user don't use Prusa Connect (I also do not), so if they did not use their printer a lot, maybe its still on an old firmware.

I wonder if we could add an update entity to Home Assistant? 🤔

Main motive of this patch is actually to have the discussion about it with someone :)

I'm ok with leaving it out for now.

Ok let's leave the workaround in place for now.

Both upstream bugs that motivated the workaround are now fixed:
  - encode/httpx#3045  (httpx 0.27.0, 2024-02-21)
  - prusa3d/Prusa-Firmware-Buddy#3665  (firmware 5.2.0, 2024-02-06)

Drops the DigestAuthWorkaround subclass and uses httpx.DigestAuth directly.
Bumps the minimum httpx dependency to 0.27.0 and documents the firmware
requirement in README.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@heikkih heikkih force-pushed the fix/remove-digest-auth-workaround branch from 62b41d4 to 478fa8b Compare April 28, 2026 11:47
Copy link
Copy Markdown
Contributor Author

@heikkih heikkih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could add an update entity to Home Assistant? 🤔

This is in my plan :)

@heikkih heikkih marked this pull request as draft April 28, 2026 11:49
@heikkih
Copy link
Copy Markdown
Contributor Author

heikkih commented Apr 28, 2026

Marking as draft for now — agreed with maintainer to hold off on removing the DigestAuthWorkaround until there's been more time to confirm the firmware 5.2.0 requirement won't break existing users.

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