fix: 治理非测试代码 unwrap/expect (#202)#206
Conversation
- 新增 EnvConfig 结构体承载已校验的 app_id/app_secret - create_config_from_env 消费返回值,删除 2 处 env::var().unwrap() - diagnose_system 适配 Ok(_) 模式 BREAKING CHANGE: check_env_config 返回值从 Result<()> 改为 Result<EnvConfig>
There was a problem hiding this comment.
💡 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> { |
There was a problem hiding this comment.
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 👍 / 👎.
改动
重构
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