Skip to content

fix: 治理非测试代码 unwrap/expect (#202)#206

Merged
foxzool merged 1 commit into
mainfrom
fix/issue-202-unwrap-treatment
Jun 15, 2026
Merged

fix: 治理非测试代码 unwrap/expect (#202)#206
foxzool merged 1 commit into
mainfrom
fix/issue-202-unwrap-treatment

Conversation

@foxzool

@foxzool foxzool commented Jun 15, 2026

Copy link
Copy Markdown
Owner

改动

重构 check_env_config 返回 EnvConfig 结构体,消除 create_config_from_env 中的 2 处 env::var().unwrap()

探索发现

原 issue 描述的 "1731 处非测试 unwrap" 经精确复核,真实库代码缺陷仅 2 处(utils.rs:104-105),其余均在 tests/ 目录或 #[cfg(test)] 模块内。

webhook/core 中的 .expect() 带 SAFETY 注释(HMAC 密钥长度、系统时间、测试运行时),逻辑上不可能失败,保留不改。

Breaking Change

check_env_config 返回值从 Result<()> 改为 Result<EnvConfig>openlark-client 处于 0.17.x Config 迁移期,utils 属内部辅助。

Closes #202

- 新增 EnvConfig 结构体承载已校验的 app_id/app_secret
- create_config_from_env 消费返回值,删除 2 处 env::var().unwrap()
- diagnose_system 适配 Ok(_) 模式

BREAKING CHANGE: check_env_config 返回值从 Result<()> 改为 Result<EnvConfig>
@foxzool foxzool added area:hr HR、招聘、考勤、薪酬等能力 type:refactor 架构或接口收敛性重构 priority:p0 当前最高优先级 scope:quality 测试、错误处理、CI 与质量门禁 labels Jun 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1fa553c3cd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

/// }
/// ```
pub fn check_env_config() -> Result<()> {
pub fn check_env_config() -> Result<EnvConfig> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve check_env_config's public return type

This changes the public openlark_client::utils::check_env_config API from Result<()> to Result<EnvConfig>, so downstream callers that match Ok(()) or otherwise name the old return type stop compiling even though the crate version remains 0.17.0; this also conflicts with the repo guideline to avoid breaking public APIs. The unwrap removal can be kept internal by adding a helper that returns the credentials for create_config_from_env while leaving check_env_config() as the compatibility wrapper returning Result<()>.

Useful? React with 👍 / 👎.

@foxzool foxzool merged commit 91491ee into main Jun 15, 2026
130 checks passed
@foxzool foxzool deleted the fix/issue-202-unwrap-treatment branch June 15, 2026 06:29
foxzool added a commit that referenced this pull request Jun 16, 2026
PR #207 误将 records 上限设为 100,与飞书官方上限 1000 冲突,
且原 500 业务规则成为死代码。改为 1000 并删除冗余检查。

code review (PR #206/#207) 发现的问题。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:hr HR、招聘、考勤、薪酬等能力 priority:p0 当前最高优先级 scope:quality 测试、错误处理、CI 与质量门禁 type:refactor 架构或接口收敛性重构

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P0:治理非测试代码中的 unwrap()/expect()

1 participant