Skip to content

fix(adsense): show report warnings and truncation in table output - #1324

Closed
saariuslystoned wants to merge 4 commits into
openclaw:mainfrom
saariuslystoned:fix/adsense-report-table-warnings
Closed

saariuslystoned wants to merge 4 commits into
openclaw:mainfrom
saariuslystoned:fix/adsense-report-table-warnings

Conversation

@saariuslystoned

@saariuslystoned saariuslystoned commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What problem this solves

adsense reports query JSON output includes the API's warnings and total_matched_rows. Table and --plain output drop both.

Per the AdSense limits and the reports.generate reference, a report is truncated at limit (default and maximum 100,000 rows). Truncation can only be detected by comparing the rows returned with totalMatchedRows. In table and --plain mode, a report cut short by --max or by the 100,000-row limit therefore looks complete, and any API warnings are never shown.

Change

In table and --plain output, writeAdSenseReportResult now prints these on stderr, so stdout stays parseable. They also print for a report with no rows, where a warning may be the only explanation:

  • each API warning, as # Warning: …;
  • when totalMatchedRows exceeds the rows returned, # Showing N of M matched rows; … to see more. Ad hoc reports suggest raising --max (up to 100000) or narrowing the report. adsense reports saved query, which has no --max, suggests narrowing the saved report, for example its date range.

JSON output is unchanged.

Evidence

TestExecute_AdSenseReportsQuery_TableShowsTruncationAndWarnings runs adsense reports query in text and --plain mode against an httptest server. The server returns 2 rows, totalMatchedRows: 250000 and one warning.

  • On main (e8428c3), stderr is empty.
  • With this change, stderr carries both notes and stdout still holds just the table.

TestExecute_AdSenseReportsQuery_EmptyTableStillShowsWarnings returns rows: [] with one warning. On main stderr is only No AdSense report rows; with this change the warning is shown as well.

The existing AdSense tests pass. TestExecute_AdSenseSavedReportTruncationHintHasNoMaxFlag checks that the saved-report note doesn't mention --max.

Built gog binaries from main and from this branch were run against a local AdSense stand-in through GOG_GOOGLE_API_BASE_URL. The stand-in is not Google:

$ gog --plain adsense reports query pub-123 --metrics estimated_earnings      (2 rows, totalMatchedRows 250000, one warning)
main:   stdout 2 rows, stderr empty
branch: stdout 2 rows, stderr "# Warning: …" and "# Showing 2 of 250000 matched rows; raise --max (up to 100000) or narrow the report to see more"
$ gog --plain adsense reports saved query accounts/pub-123/reports/report-1   (1 row, totalMatchedRows 250000)
main:   stderr empty
branch: stderr "# Showing 1 of 250000 matched rows; narrow the saved report, for example its date range to see more"
$ (rows [] plus a warning) gog --plain adsense reports query pub-123 --metrics estimated_earnings
main:   stderr "No AdSense report rows"
branch: stderr "# Warning: …" then "No AdSense report rows"

Every make ci step passed on 44384da (go1.27.3). The Go test suite ran on a second macOS arm64 machine, and the fmt, lint, deadcode, docs, agent-skills and node checks ran locally.

☁️

🤖 Generated with Claude Code

saariuslystoned and others added 3 commits November 9, 2026 01:42
adsense reports query JSON output includes the API's warnings and totalMatchedRows, but table and --plain output dropped both, so a report cut short by --max or the 100,000-row limit looked complete. Print them on stderr, keeping stdout parseable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The empty-report early return ran before the new stderr notes, so warnings explaining an empty report were still dropped in table and --plain output. Print the notes first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clawsweeper

clawsweeper Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@saariuslystoned

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 9, 2026
@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR shows AdSense report warnings and truncation counts on stderr in table and plain output.

Example: A report for pub-123 returns 2 rows, 250000 matched rows, and an API warning.

  • Before: Text output shows the two rows without warning that the report is incomplete.
  • After: Stdout retains the table; stderr shows the API warning and “Showing 2 of 250000 matched rows” with recovery advice.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct fix supported by shipped-CLI output and distinct command-level regression coverage; the previous hint defect is resolved.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The updated body records built gog binaries exercising the production report writer through the existing HTTP base-URL override, with before/after stderr and preserved table stdout for truncated ad hoc and saved reports and empty warning-bearing reports; these local output scenarios adequately exercise the changed rendering behavior without claiming successful Google access.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Users reading text reports cannot see API warnings or tell that returned rows are incomplete.
Reason: The patch exposes existing completeness information through the established diagnostic channel without changing configuration, authorization, or report requests.

Merge readiness

✅ Ready for maintainer review

This PR fixes a real omission still present on main. The prior saved-report hint finding is resolved, and no actionable defects remain.

Priority: P2
Reviewed head: 44384daa263830c83a4867580d11709d78348bcc

Before merge

None.

Findings

None.

Agent review details

How this fits together

Ad hoc and saved-report commands retrieve AdSense API responses and pass them to a shared writer that produces JSON or table stdout and human diagnostics on stderr.

flowchart TD
  A[Ad hoc report command] --> C[AdSense API client]
  B[Saved report command] --> C
  C --> D[Shared report writer]
  D --> E[JSON stdout]
  D --> F[Table stdout]
  D --> G[Diagnostic stderr]
Loading

Technical review

Best possible solution:

Retain the shared-writer fix with command-specific recovery advice and diagnostics confined to stderr.

Do we have a high-confidence way to reproduce the issue?

Current-main source directly shows the omission, and the contributor supplies matching before/after CLI output; no target code or tests were run during this read-only review.

Is this the best way to solve the issue?

The existing shared writer is the smallest complete owner for both report paths, and its early JSON return preserves structured output.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e8428c36dd31.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current-main omission: The main writer includes warnings and total_matched_rows in JSON but emits neither in text output. (internal/cmd/adsense_reports.go:116, e8428c36dd31)
  • Focused introduced change: The pinned diff adds diagnostics before the empty-report return, preserves the JSON branch, and supplies supported recovery hints for both callers. (internal/cmd/adsense_reports.go:139, 44384daa2638)
  • Previous finding resolved: Compared with the previously reviewed head, saved queries now recommend narrowing the report instead of using their unsupported --max flag; the added command-level regression checks this distinction. (internal/cmd/adsense_reports.go:322, 44384daa2638)
  • Existing completeness contract: The guide already instructs users to inspect warnings and matched-row counts before treating limited results as complete. (docs/adsense.md:52, e8428c36dd31)
  • Updated shipped-CLI proof: The full REST body supplies before/after output from built main and branch binaries using GOG_GOOGLE_API_BASE_URL: truncated ad hoc reports, truncated saved reports, and empty warning-bearing reports. The local stand-in is explicitly distinguished from Google. Captured body identity: 640f9fdc3eaa35974993d7866d7e9b4f051751b4c7b2de50f452983f1964a5dc. (44384daa2638)
  • Feature history and ownership: Path history, symbol search, blame, and the creation diff identify d40c568 as introducing the shared report writer through feat(adsense): add Google AdSense Management API support #1047; GitHub identifies ptz0n as its author and steipete as its merger. Following history beyond the creation commit encounters an unavailable old object; the creation diff itself is available. (internal/cmd/adsense_reports.go:107, d40c56847d51)

Likely related people:

  • Erik Eng: Raw commit d40c568 adds internal/cmd/adsense_reports.go:107 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d40c56847d51; files: internal/cmd/adsense_reports.go)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: AdSense text reports can appear complete despite truncation; the impact is limited to report interpretation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-09T07:07:48.470Z sha 90e9199 :: needs real behavior proof before merge. :: [P3] Give saved reports a supported recovery hint

Reviewed November 9, 2026, 11:34 AM ET / 16:34 UTC (Revision 2).

Saved reports have no --max flag, so suggest narrowing the saved report instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 9, 2026
@steipete

Copy link
Copy Markdown
Collaborator

Thank you for the fix. I reproduced the claim and consolidated showing AdSense warnings and truncation hints on stderr into #1336, with regression coverage and your coauthor credit retained. The full make ci gate, built-CLI checks for the new request-validation fixes, and exact-head GitHub CI passed. Closing this PR as superseded by the merged implementation in #1336.

@steipete steipete closed this Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants