Skip to content

feat: add Update-PiHoleList, completing the Lists API area - #113

Merged
mikemadeja merged 1 commit into
developfrom
feature/update-pihole-list
Sep 25, 2026
Merged

mikemadeja merged 1 commit into
developfrom
feature/update-pihole-list

Conversation

@mikemadeja

Copy link
Copy Markdown
Owner

Summary

Implements PUT /api/lists/{list}, the last missing piece of List management - Add-PiHoleList's own "already exists" error has referenced this function by name since it was written. Updates an existing list's Comment, Group(s), and/or Enabled state.

Like Update-PiHoleGroup, the underlying API replaces the entire list on update, so this reads the list's current values first and only overrides whichever of Comment/Group/Enabled was actually passed - using the same $PSBoundParameters.ContainsKey() pattern (rather than checking parameter values for $null), since that was the actual root cause of the bug fixed in Update-PiHoleGroup: an unbound [string] binds to "", and [bool] can never be $null, so value-based checks can't reliably detect "not passed".

Verified type only needs to be a query parameter (?type=block), not also in the request body, by testing directly against the real server - the API's own documented PUT body schema lists type as a body field too, but (like the POST endpoint's documented schema, which turned out to expect type in the query string only despite listing it in the body schema) the server accepted both a query-only and query+body request identically.

The other remaining Lists gap, DELETE /lists/{list} (single item), isn't being added as a separate function: Remove-PiHoleList already achieves the same outcome via the batch endpoint (a batch of one) - same reasoning already applied to skip the deprecated POST /action/flush/arp.

With this merged, Lists is fully covered.

Test plan

  • Invoke-ScriptAnalyzer -Path .\PiHoleShell -Recurse - clean
  • Verified against a real Pi-hole v6 server: partial updates (confirming the untouched field is preserved), -RawOutput, and not-found/missing-parameter/bad-password errors
  • New integration test file, 6 tests, all passing (re-ran after an initial transient failure caused by the real test server - a Raspberry Pi Zero W under this session's cumulative load - being unusually slow; confirmed not a code bug by re-running clean)
  • Full non-integration suite passes with no regressions (149 tests)
  • Regenerated README.md

🤖 Generated with Claude Code

Implements PUT /api/lists/{list}, the last missing piece of List
management - Add-PiHoleList's own "already exists" error has referenced
this function by name since it was written. Updates an existing list's
Comment, Group(s), and/or Enabled state.

Like Update-PiHoleGroup, the underlying API replaces the entire list on
update, so this reads the list's current values first and only overrides
whichever of Comment/Group/Enabled was actually passed - using the same
$PSBoundParameters.ContainsKey() pattern (rather than checking parameter
values for $null), since that was the actual root cause of the bug fixed
in Update-PiHoleGroup: an unbound [string] binds to "", and [bool] can
never be $null, so value-based checks can't reliably detect "not passed".

Verified type only needs to be a query parameter (?type=block), not also
in the request body, by testing directly against the real server - the
API's own documented PUT body schema lists `type` as a body field too, but
(like the POST endpoint's documented schema, which turned out to expect
type in the query string only despite listing it in the body schema) the
server accepted both a query-only and query+body request identically.

The other remaining Lists gap, DELETE /lists/{list} (single item), isn't
being added as a separate function: Remove-PiHoleList already achieves the
same outcome via the batch endpoint (a batch of one) - same reasoning
already applied to skip the deprecated POST /action/flush/arp.

Verified against a real Pi-hole v6 server: partial updates (confirming the
untouched field is preserved), RawOutput, and not-found/missing-parameter/
bad-password errors. Added a dedicated integration test file (6 tests).
README regenerated.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mikemadeja
mikemadeja merged commit 843fd4d into develop Sep 25, 2026
2 of 3 checks passed
@mikemadeja mikemadeja mentioned this pull request Sep 25, 2026
1 task done
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.

1 participant