fix: Align Cargo features with cfg gates across all crates#101
Conversation
修复 #97 新增安全政策文档,包含: - 支持的版本列表(0.15.x, 0.14.x) - 漏洞报告流程(GitHub Security Advisories + 邮件) - 响应时间承诺(48小时内确认、5天内评估) - 安全更新策略和发布流程 - 使用最佳实践建议
修复内容: - 统一所有 crate 的 feature 定义与代码中 #[cfg(feature = ...)] 的使用 - 修复根 crate 中缺失 feature 依赖的问题 (workflow, platform, application, helpdesk, mail, analytics, user) - 在 openlark-client 中添加缺失的 feature 支持 (ai, workflow, platform, application, helpdesk, mail, analytics, user, security) - 为没有 Client 类型的子 crate 创建类型别名 (WorkflowClient, PlatformClient 等) - 更新 ServiceRegistry bootstrap 以注册新服务 - 修复根 crate lib.rs 中的重复导入问题 关联: - Issue: #40
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0bea99affd
ℹ️ 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".
| }; | ||
| register(registry, metadata) | ||
| } | ||
| fn register_ai(registry: &mut DefaultServiceRegistry) -> Result<()> { |
There was a problem hiding this comment.
Deduplicate AI registry helper under feature gates
This file now defines register_ai twice (one #[cfg(feature = "ai")] version and one unconditional version), so when ai is enabled both symbols are compiled and Rust raises E0428 for a duplicate definition. That breaks openlark-client builds for any consumer enabling the ai feature.
Useful? React with 👍 / 👎.
|
|
||
| /// Security meta 调用链入口:client.security.acs... ... | ||
| #[cfg(feature = "security")] | ||
| pub security: openlark_security::SecurityClient, |
There was a problem hiding this comment.
Use exported security service type in client field
The new security field references openlark_security::SecurityClient, but openlark-security does not export that type (it exposes SecurityServices), so enabling the security feature fails with unresolved type/import errors. This makes the feature unusable in openlark-client and any root crate that forwards it.
Useful? React with 👍 / 👎.
| let workflow = crate::WorkflowClient::new(core_config.clone()); | ||
|
|
||
| #[cfg(feature = "platform")] | ||
| let platform = crate::PlatformClient::new(core_config.clone()); |
There was a problem hiding this comment.
Propagate fallible service constructors in client setup
PlatformClient::new (and similarly AnalyticsClient::new / UserClient::new) returns a Result, but this code stores it as if it were the final service value. The struct initializer later expects concrete service types, which causes E0308 type mismatches when these features are enabled. Client::with_config needs to handle these fallible constructors (e.g., with ?) before building Client.
Useful? React with 👍 / 👎.
|
|
||
| /// Workflow meta 调用链入口:client.workflow.task.create() ... | ||
| #[cfg(feature = "workflow")] | ||
| pub workflow: crate::WorkflowClient, |
There was a problem hiding this comment.
Avoid Debug-bound breakage from new service aliases
The newly added workflow/application/helpdesk/mail fields use service alias types that do not implement Debug, but Client still derives Debug. Enabling any of those features triggers E0277 and prevents compilation, so these fields should not introduce non-Debug members into a Debug-derived struct without an adaptation.
Useful? React with 👍 / 👎.
|
@codex review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19a0a275a2
ℹ️ 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".
|
|
||
| /// Security meta 调用链入口:client.security.acs... ... | ||
| #[cfg(feature = "security")] | ||
| pub security: openlark_security::SecurityClient, |
There was a problem hiding this comment.
Replace nonexistent
SecurityClient references
The security feature path now references openlark_security::SecurityClient, but that type is not exported by openlark-security (it exposes SecurityServices). As a result, enabling security causes immediate compile failures (E0412/E0432/E0433) in openlark-client, so consumers cannot build with this feature.
Useful? React with 👍 / 👎.
| let workflow = crate::WorkflowClient::new(core_config.clone()); | ||
|
|
||
| #[cfg(feature = "platform")] | ||
| let platform = crate::PlatformClient::new(core_config.clone()); |
There was a problem hiding this comment.
Handle fallible service constructors in
with_config
The newly wired platform/analytics/user services are instantiated as if new(...) returns a concrete service, but these constructors return SDKResult<_> (and expect specialized config types). Storing the raw result in Client fields leads to E0308 type mismatches whenever those features are enabled, so these feature combinations no longer compile.
Useful? React with 👍 / 👎.
|
|
||
| /// Workflow meta 调用链入口:client.workflow.task.create() ... | ||
| #[cfg(feature = "workflow")] | ||
| pub workflow: crate::WorkflowClient, |
There was a problem hiding this comment.
Preserve
Client Debug derivation with new feature fields
Client derives Debug, but newly added fields like workflow, application, helpdesk, and mail alias service structs that do not implement Debug. Enabling any of these features triggers E0277 in derive expansion, making those feature-gated builds fail even though they are now advertised as supported.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9b70cec87a
ℹ️ 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 type UserClient = openlark_user::UserService; | ||
|
|
||
| #[cfg(feature = "security")] | ||
| pub use openlark_security::SecurityClient; |
There was a problem hiding this comment.
Re-export the actual security type
This re-export points to openlark_security::SecurityClient, but openlark-security only exposes SecurityServices. With security enabled, cargo check -p openlark-client --no-default-features --features security fails with no SecurityClient in the root, so downstream users cannot compile this feature.
Useful? React with 👍 / 👎.
|
|
||
| /// Security meta 调用链入口:client.security.acs... ... | ||
| #[cfg(feature = "security")] | ||
| pub security: openlark_security::SecurityServices, |
There was a problem hiding this comment.
Fix security client wiring to compile with Clone/Config types
Adding SecurityServices directly as a Client field breaks the #[derive(Clone)] on Client because SecurityServices is not Clone, and the new initialization path also constructs it from core_config even though SecurityServices::new expects SecurityConfig. In practice, enabling security makes the crate fail to build, so this feature gate is currently unusable.
Useful? React with 👍 / 👎.
|
@codex address that feedback |
Summary
Testing
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8faf3142e1
ℹ️ 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".
Summary
修复 #40 - Feature gate 对齐问题
修复内容
的使用
验证
关联
Fixes #40