Skip to content

Promote develop to main - #108

Merged
mikemadeja merged 6 commits into
mainfrom
develop
Sep 24, 2026
Merged

mikemadeja merged 6 commits into
mainfrom
develop

Conversation

@mikemadeja

Copy link
Copy Markdown
Owner

Summary

Promotes the following merged PRs from develop to main:

Test plan

  • All three source PRs passed PSScriptAnalyzer and the full Pester suite (including real-server integration tests) in CI before merging into develop

🤖 Generated with Claude Code

mikemadeja and others added 6 commits September 23, 2026 17:13
Implements the previously-missing "History" area of the Pi-hole v6 API
(GET /history, /history/database, /history/clients, /history/database/clients)
as new PiHoleShell/Public/History functions:

- Get-PiHoleHistory - live "total queries over time" graph data (~last 24h)
- Get-PiHoleHistoryDatabase - same, from the long-term on-disk database, with
  From/Until (defaulting to the last 8 hours, matching the existing
  Stats(database) functions' convention)
- Get-PiHoleHistoryClient - live per-client activity graph data, one object
  per timestamp with a nested Clients breakdown (IP/Name/Count)
- Get-PiHoleHistoryDatabaseClient - same, from the long-term database

Get-PiHoleHistoryDatabaseClient has one notable wrinkle, verified against a
real server: the API keys its per-timestamp client breakdown by an internal
numeric client ID, not by IP, while the separate client summary it also
returns is keyed by IP - there's no shared key to join the two on. So this
function returns ClientId as-is rather than pretending to resolve a
name/IP it doesn't actually have (documented in its .DESCRIPTION).

Verified against a real Pi-hole v6 server, all 4 functions, both formatted
and RawOutput, plus bad-password error handling. Added dedicated
integration test files per function (14 tests total). README regenerated.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The "errors when given a bad password" tests printed the entire captured
-ErrorVariable array via Write-Host "Error: [\$errOut]". For functions that
make several internal calls before their own API call (e.g. Add-PiHoleList
calls Get-PiHoleList and Get-PiHoleGroup first, both of which also
authenticate), a single bad password produces one error entry per nested
auth failure - each one a multi-line HttpResponseException dump - plus the
final, actually-relevant error repeated several times as it re-wraps through
each layer's own catch block. All of that got dumped to the console.

None of this affected correctness - the assertion only checks that $errOut
is non-empty - but the wall of text made the test output hard to read for
no benefit. Now prints the entry count and just the last (most relevant)
error instead.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
feat: add History feature (4 new functions)
… tests

New-PiHoleGroup, Update-PiHoleGroup, and Remove-PiHoleGroup all had the same
stray break in their catch blocks (silently aborts the entire calling
script on error, even with -ErrorAction SilentlyContinue) and were missing
proper comment-based help.

Update-PiHoleGroup had two more serious bugs, found while writing tests:
- The PUT /groups/{name} endpoint replaces the whole group, per its own API
  docs ("Ensure to send all the required parameters... to ensure these
  properties are retained"). The function only sent whichever of
  Comment/Enabled the caller passed, so updating just one would silently
  wipe the other back to its default (Comment to $null, Enabled to $false).
  Now reads the group's current values first and only overrides the
  field(s) actually passed.
- [bool]$Enabled can never be $null in PowerShell, so the existing
  "$Enabled -eq $null" checks (both the "you must specify something"
  validation and the "keep current value" fallback) could never be true -
  changed to [Nullable[bool]] and switched all "was this passed" checks to
  $PSBoundParameters.ContainsKey(), which is the only case-proof way to
  detect an omitted parameter (also caught the same problem with $Comment:
  an unbound [string] parameter binds to "" not $null, regardless of
  whether you write "= $null" as its default).

Also switched New-PiHoleGroup and Update-PiHoleGroup's formatted output to
reflect the real API response (name/comment/enabled/id/dates) instead of
echoing back the input parameters, matching the rest of the module.
Remove-PiHoleGroup's WIP flag is dropped now that it's verified working.

Verified against a real Pi-hole v6 server using a "PesterGroup" test group:
create, duplicate-create warning, partial updates (confirming the other
field is preserved), update validation/not-found errors, delete, and
bad-password errors for all three functions. Added dedicated integration
test files (14 tests). README regenerated.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ostics

test: trim noisy bad-password error diagnostics
fix: make GroupManagement functions production ready, add integration tests
@mikemadeja
mikemadeja merged commit d5867e3 into main Sep 24, 2026
5 checks passed
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