Skip to content

fix(config): allow lark-channel bind source override#1154

Merged
HanShaoshuai-k merged 1 commit into
mainfrom
feat/channel_profile
May 28, 2026
Merged

fix(config): allow lark-channel bind source override#1154
HanShaoshuai-k merged 1 commit into
mainfrom
feat/channel_profile

Conversation

@HanShaoshuai-k
Copy link
Copy Markdown
Collaborator

@HanShaoshuai-k HanShaoshuai-k commented May 28, 2026

Summary

Allow lark-cli config bind --source lark-channel to read the lark-channel source config from LARK_CHANNEL_CONFIG when provided, while keeping the existing ~/.lark-channel/config.json default unchanged.

Changes

  • Add LARK_CHANNEL_CONFIG support to lark-channel bind source path resolution.
  • Preserve the existing default path behavior when the env var is unset or empty.
  • Add tests for both default path resolution and env override with ~ expansion.

Test Plan

  • go test ./cmd/config ./internal/binding
  • make build
  • git diff --check

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • The Lark channel config path can now be configured using the LARK_CHANNEL_CONFIG environment variable with tilde expansion support.
  • Tests

    • Added comprehensive test coverage for config path resolution with default and environment override scenarios.

Review Change Stack

Change-Id: I406ea13e372e6bdd5f3d9d6210b04ebdf0354182
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

📝 Walkthrough

Walkthrough

This PR extends resolveLarkChannelConfigPath to support the LARK_CHANNEL_CONFIG environment variable as an override mechanism. When set, the variable's value (with home directory expansion) is used; when empty or unset, the function falls back to the existing default path computation. New tests validate both the default and override behaviors.

Changes

Lark Channel Config Path Override

Layer / File(s) Summary
Config path override implementation
cmd/config/binder.go
resolveLarkChannelConfigPath now checks LARK_CHANNEL_CONFIG and, if non-empty, returns the home-expanded override value instead of the default ~/.lark-channel/config.json path.
Config path resolution tests
cmd/config/binder_test.go
Two test functions verify default behavior (using HOME when LARK_CHANNEL_CONFIG is empty) and override behavior (using LARK_CHANNEL_CONFIG with ~ expansion). The path/filepath import is added to support path assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • larksuite/cli#786: Extends the bind-source wiring that depends on resolveLarkChannelConfigPath for lark-channel configuration.

Suggested labels

size/L

Suggested reviewers

  • liangshuo-1

Poem

🐰 A config path that bends to will,
With env var keys and tilde's thrill,
Fallback defaults stand ever near,
Tests prove both paths crystal clear! 🌲

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: allowing a lark-channel bind source override via environment variable, which matches the core functionality added in the changeset.
Description check ✅ Passed The pull request description includes all required sections from the template with substantial, relevant content: a clear summary, detailed changes list, comprehensive test plan with verification steps, and related issues section.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/channel_profile

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the size/L Large or sensitive change across domains or core paths label May 28, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/config/binder.go`:
- Around line 395-397: The code currently returns expandHome(p) for the
environment override LARK_CHANNEL_CONFIG without validating the resulting path;
before calling binding.ReadLarkChannelConfig(...) validate the resolved override
by passing the expanded path through validate.SafeInputPath (or equivalent) and
handle validation errors (log/return) so untrusted env values are rejected;
update the branch that reads os.Getenv("LARK_CHANNEL_CONFIG") and the value
produced by expandHome to be validated via validate.SafeInputPath prior to any
file reads.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 027a306c-860d-4386-871b-8308dd78b627

📥 Commits

Reviewing files that changed from the base of the PR and between 3cd84fc and c4c9494.

📒 Files selected for processing (2)
  • cmd/config/binder.go
  • cmd/config/binder_test.go

Comment thread cmd/config/binder.go
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.64%. Comparing base (bbef3cb) to head (c4c9494).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1154      +/-   ##
==========================================
+ Coverage   68.61%   68.64%   +0.02%     
==========================================
  Files         625      625              
  Lines       58348    58391      +43     
==========================================
+ Hits        40035    40081      +46     
+ Misses      15029    15023       -6     
- Partials     3284     3287       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@c4c9494075249f081caf7b5ac32dfebe90bb0645

🧩 Skill update

npx skills add larksuite/cli#feat/channel_profile -y -g

@HanShaoshuai-k HanShaoshuai-k merged commit 01fe71d into main May 28, 2026
29 of 31 checks passed
@HanShaoshuai-k HanShaoshuai-k deleted the feat/channel_profile branch May 28, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants