refactor(core,ai,+8): HTTP 管道 helper 下沉 core::api + ai common 私有化(#330)#345
Conversation
…uccess 下沉 core::api + ai common 私有化(#330) - core::api 加 canonical helpers(serialize_params/extract_response_data/ensure_success, rich 诊断 operation/resource/request_id via map_context) - 10 业务 crate 的 common/api_utils.rs 改 re-export core canonical(签名不变,调用点零改动): ai/application/helpdesk/mail/platform/meeting/cardkit/communication 纯 re-export; workflow 保留 missing_response_data_error+request_serialization_error(外部用); docs 保留 missing_response_data_error;meeting 保留 validate_required_field - openlark-ai pub mod common → mod common(HTTP helper 不再公开泄漏) - 各 crate api_url! macro 移除 #[macro_export](零生产调用) - CHANGELOG v0.18 breaking 本地全过:workspace build/test 7267 passed、clippy 矩阵(--all-features/--no-default-features -Dwarnings)、 fmt、CI 三连(machete/doc -D/msrv --locked)。
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96f8acb004
ℹ️ 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".
| assert!(url.contains("approve")); | ||
| } | ||
| } | ||
| pub use openlark_core::api::{ensure_success, extract_response_data, serialize_params}; |
There was a problem hiding this comment.
Preserve communication error component context
For communication APIs that call extract_response_data or serialize_params, this re-export now routes failures through the core helper, which only sets operation/resource/request_id and no longer sets component=openlark-communication as the removed wrappers did. docs/error-context-policy.md requires component for these standardized errors, so failures in paths like contact user/department requests lose crate attribution in logs and diagnostics; keep thin per-crate wrappers or use a component-aware core helper here.
Useful? React with 👍 / 👎.
| use openlark_core::error; | ||
|
|
||
| // canonical HTTP 管道 helper(#330 下沉到 core) | ||
| pub use openlark_core::api::{ensure_success, extract_response_data, serialize_params}; |
There was a problem hiding this comment.
Keep docs helper exports source-compatible
Because openlark_docs::common is still public, replacing the module with only these re-exports drops previously public helpers such as validate_required_field and request_serialization_error. External users that followed the public openlark_docs::common::api_utils::* path for validation/serialization error helpers will now fail to compile, and this removal is not covered by the documented breaking changes; keep compatibility wrappers or explicitly migrate these symbols.
Useful? React with 👍 / 👎.
What
issue #330(补审 #313 confirmed "通用 HTTP helper 下沉缺失"):
serialize_params/extract_response_data/ensure_success此前在 10 个业务 crate 各有一份common/api_utils.rs(locality 失守),统一到openlark_core::apicanonical。改动
core::api 加 canonical(
api/helpers.rs,rich 诊断:operation/resource/request_idviamap_context):serialize_params(params, context)、extract_response_data(response, context)、ensure_success(response, context)10 crate re-export(签名不变,调用点零改动——
crate::common::api_utils::serialize_paramsresolve 到 re-export 即 core canonical):missing_response_data_error(15文件)/request_serialization_error(11文件)(域专用 error 构造器,外部用)missing_response_data_error(1文件)validate_required_field(11文件)ai 私有化:
pub mod common→mod common(HTTP helper 不再公开泄漏;仓内零外部引用)api_url!移除#[macro_export](各 crate,零生产调用,语义等同format!)设计
common::api_utils路径(re-export core),避免改 ~1100 个调用点;single source of truth 在 core,无 divergence。验证(含 CI 三连 + clippy 矩阵,本地预跑)
cargo build/test --workspace --all-features:7267 passed / 0 failed--all-features+--no-default-features全-Dwarnings干净ci-only-checks-deletion-triad):machete 干净 /cargo doc -D warnings干净 / msrv--locked通过(Cargo.lock 未变,无新 dep)close #330