Skip to content

fix: handle ignored io.ReadAll errors across codebase#1142

Merged
mengzhuo merged 7 commits intosipeed:mainfrom
mattn:fix/handle-io-readall-errors
Mar 6, 2026
Merged

fix: handle ignored io.ReadAll errors across codebase#1142
mengzhuo merged 7 commits intosipeed:mainfrom
mattn:fix/handle-io-readall-errors

Conversation

@mattn
Copy link
Contributor

@mattn mattn commented Mar 5, 2026

📝 Description

io.ReadAll errors were silently discarded with body, _ := io.ReadAll(...), which could cause empty or partial data to be used for JSON unmarshaling or error messages. This adds proper error checks for all instances.

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

📚 Technical Context (Skip for Docs)

  • Reference URL:
  • Reasoning:

🧪 Test Environment

  • Hardware:
  • OS:
  • Model/Provider:
  • Channels:

📸 Evidence (Optional)

Click to view Logs/Screenshots

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

io.ReadAll errors were silently discarded with `body, _ := io.ReadAll(...)`,
which could cause empty or partial data to be used for JSON unmarshaling
or error messages. This adds proper error checks for all instances.
Copilot AI review requested due to automatic review settings March 5, 2026 12:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves reliability of HTTP response handling by ensuring io.ReadAll(...) errors are not silently ignored, preventing downstream logic from operating on empty/partial bodies (e.g., JSON parsing, error reporting).

Changes:

  • Replace body, _ := io.ReadAll(...) with body, err := io.ReadAll(...) across multiple packages.
  • Add early returns with contextual errors when reading response bodies fails.
  • Improve error-path diagnostics by ensuring error responses are read (when possible) before formatting error messages.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/providers/antigravity_provider.go Adds io.ReadAll error handling for Antigravity API responses.
pkg/channels/wecom/bot.go Adds io.ReadAll error handling in webhook reply error path.
pkg/channels/wecom/app.go Adds io.ReadAll error handling for WeCom app upload/send error responses.
pkg/channels/wecom/aibot.go Adds io.ReadAll error handling for response_url failure bodies.
pkg/channels/line/line.go Adds io.ReadAll error handling for LINE API error responses.
pkg/auth/oauth.go Adds io.ReadAll error handling for OAuth device/token flows.
cmd/picoclaw/internal/auth/helpers.go Adds io.ReadAll error handling for Google userinfo fetch.
cmd/picoclaw-launcher/internal/server/auth_handlers.go Adds io.ReadAll error handling for Google userinfo fetch.
cmd/picoclaw-launcher-tui/internal/ui/model.go Adds io.ReadAll error handling when reading limited error responses in model test UI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 5, 2026 12:20
mattn and others added 3 commits March 5, 2026 21:20
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mattn
Copy link
Contributor Author

mattn commented Mar 5, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

mattn added 2 commits March 5, 2026 21:54
Combine both shadow variable fix (readErr) and proper error
classification (ClassifySendError) in wecom app and bot channels.
Copilot AI review requested due to automatic review settings March 5, 2026 13:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@huaaudio huaaudio left a comment

Choose a reason for hiding this comment

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

Solid PR that handles ignored error catching. LGTM

@mengzhuo mengzhuo merged commit 8581d46 into sipeed:main Mar 6, 2026
7 of 8 checks passed
dj-oyu pushed a commit to dj-oyu/picoclaw that referenced this pull request Mar 8, 2026
fix: handle ignored io.ReadAll errors across codebase
fishtrees pushed a commit to fishtrees/picoclaw that referenced this pull request Mar 12, 2026
fix: handle ignored io.ReadAll errors across codebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants