Skip to content

fix: Align Cargo features with cfg gates across all crates#101

Merged
foxzool merged 6 commits intomainfrom
fix/feature-gate-alignment-40
Apr 9, 2026
Merged

fix: Align Cargo features with cfg gates across all crates#101
foxzool merged 6 commits intomainfrom
fix/feature-gate-alignment-40

Conversation

@foxzool
Copy link
Copy Markdown
Owner

@foxzool foxzool commented Apr 9, 2026

Summary

修复 #40 - Feature gate 对齐问题

修复内容

  • ✅ 统一根 crate 和所有子 crate 的 feature 定义与代码中
    的使用
  • ✅ 修复根 crate 中缺失 feature 依赖的问题:
    • workflow: 添加 auth 依赖和 openlark-client/workflow 映射
    • platform: 添加 auth 依赖和 openlark-client/platform 映射
    • application: 添加 auth 依赖和 openlark-client/application 映射
    • helpdesk: 添加 auth 依赖和 openlark-client/helpdesk 映射
    • mail: 添加 auth 依赖和 openlark-client/mail 映射
    • analytics: 添加 auth 依赖和 openlark-client/analytics 映射
    • user: 添加 auth 依赖和 openlark-client/user 映射
    • ai: 添加 auth 依赖(统一依赖规范)
  • ✅ 在 openlark-client 中添加缺失的 feature 支持:
    • 为 ai, workflow, platform, application, helpdesk, mail, analytics, user, security 添加字段
    • 为没有 Client 类型的子 crate 创建类型别名 (WorkflowClient, PlatformClient 等)
    • 更新 ServiceRegistry bootstrap 以注册新服务
  • ✅ 修复根 crate lib.rs 中的重复导入问题

验证

  • cargo check -p openlark-client 通过
  • cargo check -p openlark 通过
  • 无重复 feature key 错误

关联

Fixes #40

foxzool added 2 commits April 9, 2026 16:59
修复 #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
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 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<()> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread crates/openlark-client/src/client.rs Outdated

/// Security meta 调用链入口:client.security.acs... ...
#[cfg(feature = "security")]
pub security: openlark_security::SecurityClient,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread crates/openlark-client/src/client.rs Outdated
let workflow = crate::WorkflowClient::new(core_config.clone());

#[cfg(feature = "platform")]
let platform = crate::PlatformClient::new(core_config.clone());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

修复内容:
- 删除 bootstrap.rs 中重复的 register_ai 函数
- 修复根 crate lib.rs 中的 SecurityClient/Services 类型引用

关联:
- PR: #101
- Issue: #40
@foxzool
Copy link
Copy Markdown
Owner Author

foxzool commented Apr 9, 2026

@codex review

@foxzool
Copy link
Copy Markdown
Owner Author

foxzool commented Apr 9, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 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".

Comment thread crates/openlark-client/src/client.rs Outdated

/// Security meta 调用链入口:client.security.acs... ...
#[cfg(feature = "security")]
pub security: openlark_security::SecurityClient,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread crates/openlark-client/src/client.rs Outdated
let workflow = crate::WorkflowClient::new(core_config.clone());

#[cfg(feature = "platform")]
let platform = crate::PlatformClient::new(core_config.clone());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

修复内容:
- 移除 #[derive(Debug)],手动实现 Debug trait 以避免非 Debug 字段问题
- 修复 SecurityClient -> SecurityServices 类型引用
- 为 PlatformClient::new, AnalyticsClient::new, UserClient::new 添加 ? 传播 Result

关联:
- PR: #101
- Issue: #40
@foxzool
Copy link
Copy Markdown
Owner Author

foxzool commented Apr 9, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 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".

Comment thread crates/openlark-client/src/lib.rs Outdated
pub type UserClient = openlark_user::UserService;

#[cfg(feature = "security")]
pub use openlark_security::SecurityClient;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread crates/openlark-client/src/client.rs Outdated

/// Security meta 调用链入口:client.security.acs... ...
#[cfg(feature = "security")]
pub security: openlark_security::SecurityServices,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@foxzool
Copy link
Copy Markdown
Owner Author

foxzool commented Apr 9, 2026

@codex address that feedback

@chatgpt-codex-connector
Copy link
Copy Markdown

Summary

  • Addressed the security feature wiring in Client by changing Client.security to use a clone-friendly alias (crate::SecurityClient) instead of directly storing SecurityServices, which fixes Clone derivation breakage under the security feature.
  • Fixed Client::with_config security initialization to construct openlark_security::models::SecurityConfig from client config (app_id, app_secret, base_url) before creating SecurityServices, resolving the config type mismatch error path for security builds.
  • Replaced the invalid openlark_security::SecurityClient re-export with a local SecurityClient alias (Arc<SecurityServices>) and updated prelude exports to point to that alias, resolving unresolved import failures when security is enabled.
  • Committed the fix on the current branch as ded3a9b and created a follow-up PR via the make_pr tool with a title/body describing these review-driven fixes.

Testing

  • cargo check -p openlark-client --no-default-features --features security
  • cargo check -p openlark-client --no-default-features --features platform,auth
  • cargo check -p openlark-client --no-default-features --features analytics,auth
  • cargo check -p openlark-client --no-default-features --features user,auth
  • cargo check -p openlark-client --no-default-features --features workflow,application,helpdesk,mail,auth
  • cargo fmt --all
  • rustfmt crates/openlark-client/src/client.rs crates/openlark-client/src/lib.rs (failed because direct rustfmt invocation defaulted to an older edition parsing mode; formatting had already been applied successfully via cargo fmt --all)

View task →

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 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".

Comment thread src/lib.rs
@foxzool foxzool merged commit c1f2a82 into main Apr 9, 2026
38 of 46 checks passed
@foxzool foxzool deleted the fix/feature-gate-alignment-40 branch April 9, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align Cargo features with cfg gates across all crates

1 participant