Skip to content

Check errcode in ILinkClient::api_post#71

Merged
jiweiyuan merged 1 commit into
corespeed-io:mainfrom
lewiszlw:check-errcode
Apr 27, 2026
Merged

Check errcode in ILinkClient::api_post#71
jiweiyuan merged 1 commit into
corespeed-io:mainfrom
lewiszlw:check-errcode

Conversation

@lewiszlw

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings April 24, 2026 10:00

Copilot AI left a comment

Copy link
Copy Markdown

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 Rust SDK error handling for iLink API calls by treating non-zero errcode responses as failures even when the HTTP status is successful.

Changes:

  • Add errcode != 0 checking in ILinkClient::api_post and return WeChatBotError::Api on API-level failures.
  • Update Cargo.lock to reflect the wechatbot crate version 0.3.1.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
rust/src/protocol.rs Adds API-level errcode validation in api_post so callers don’t silently accept error responses with HTTP 200.
rust/Cargo.lock Locks crate version update to 0.3.1.

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

Comment thread rust/src/protocol.rs
Comment on lines +236 to +240
message: value["errmsg"]
.as_str()
.or_else(|| value["message"].as_str())
.unwrap_or(&text)
.to_string(),

Copilot AI Apr 24, 2026

Copy link

Choose a reason for hiding this comment

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

The error message extraction here (errmsg -> message -> raw text) differs from the earlier status >= 400 branch, which only checks errmsg. Consider extracting a small helper/closure to compute the API error message once and reusing it in both branches to keep behavior consistent and avoid duplicated parsing logic.

Copilot uses AI. Check for mistakes.
@jiweiyuan jiweiyuan merged commit ca857a8 into corespeed-io:main Apr 27, 2026
15 of 16 checks passed
@jiweiyuan jiweiyuan mentioned this pull request Apr 27, 2026
1 task
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.

3 participants