fix(strict-mode): reject explicit --as instead of silently overriding it#673
fix(strict-mode): reject explicit --as instead of silently overriding it#673sang-neo03 merged 2 commits intomainfrom
Conversation
ResolveAs checked strict mode before the --as flag, so `--as bot` under strict=user was silently rewritten to user. Reorder so explicit --as is returned as-is and CheckStrictMode rejects the conflict (exit=2). Implicit paths (--as auto / unset) are still forced by strict mode.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughResolveAs now defers applying strict-mode forced identities until after explicit Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/root_integration_test.go (1)
152-164: Remove unusedparseDryRunJSONfunction.This helper function at lines 152–164 is no longer called anywhere in the file after the refactor to envelope assertions. Removing it will eliminate the dead code and its
stringsusage (thoughstringsis still used elsewhere in the file).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmd/root_integration_test.go` around lines 152 - 164, Remove the unused helper function parseDryRunJSON from the test file: delete the parseDryRunJSON function declaration (including its t.Helper call, prefix check, JSON unmarshal, and return) since it's no longer referenced after switching to envelope assertions; ensure any import only used by that function (if now unused) is cleaned up by the importer (e.g., remove strings if it becomes unused).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@cmd/root_integration_test.go`:
- Around line 152-164: Remove the unused helper function parseDryRunJSON from
the test file: delete the parseDryRunJSON function declaration (including its
t.Helper call, prefix check, JSON unmarshal, and return) since it's no longer
referenced after switching to envelope assertions; ensure any import only used
by that function (if now unused) is cleaned up by the importer (e.g., remove
strings if it becomes unused).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a502268c-90f6-4a7f-b9a5-80043dc90c7f
📒 Files selected for processing (3)
cmd/root_integration_test.gointernal/cmdutil/factory.gointernal/cmdutil/factory_test.go
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@973f73d647d0022a50fdd1d328aa3cebca62cca4🧩 Skill updatenpx skills add larksuite/cli#fix/strict-mode-explicit-as-reject -y -g |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #673 +/- ##
=======================================
Coverage 62.96% 62.96%
=======================================
Files 436 436
Lines 38604 38605 +1
=======================================
+ Hits 24306 24307 +1
Misses 12150 12150
Partials 2148 2148 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
ResolveAs checked strict mode before the
--asflag, so--as botunder strict=user was silently rewritten to user. Reorder so explicit--asis returned as-is andCheckStrictModerejects the conflict (exit=2). Implicit paths (--as auto/ unset) are still forced by strict mode.Changes
ResolveAsininternal/cmdutil/factory.goso explicit--as user|botis returned before strict-mode forcing; strict mode only forces implicit paths.internal/cmdutil/factory_test.goto cover explicit-vs-strict preservation and--as autoforcing.cmd/root_integration_test.gofor shortcut / service / api paths to assert thestrict_modevalidation envelope instead of silent override.Test Plan
go test ./internal/cmdutil/... -run TestResolveAs_StrictMode)go test ./cmd/... -run TestIntegration_StrictMode)lark-cli im +chat-create --as bot --dry-run/lark-cli im chats get --as bot --dry-run/lark-cli api --as bot GET ... --dry-runall return exit=2 withstrict_modeenvelope;--as user/--as auto/ unset still succeed. Symmetric checks under strict=bot also pass.Related Issues
Summary by CodeRabbit
Bug Fixes
Tests