Skip to content

fix: allow all files for base form attachment questions#931

Open
LawyerLyu wants to merge 1 commit into
larksuite:mainfrom
LawyerLyu:fix/base-form-attachment-file-types
Open

fix: allow all files for base form attachment questions#931
LawyerLyu wants to merge 1 commit into
larksuite:mainfrom
LawyerLyu:fix/base-form-attachment-file-types

Conversation

@LawyerLyu
Copy link
Copy Markdown
Contributor

@LawyerLyu LawyerLyu commented May 17, 2026

Summary

Fixes Base form attachment questions so they default to accepting all file types, matching the Feishu UI behavior for newly created attachment questions.

Changes

  • Add normalization for base +form-questions-create attachment questions so missing or null attachment.file_types becomes ["all"].
  • Preserve explicitly supplied attachment file_types values.
  • Include the normalized request body in dry-run output for this shortcut.
  • Document the attachment question configuration and default behavior in the Base skill reference.

Test Plan

  • Unit tests pass: go test ./shortcuts/base
  • Manual local verification confirms the lark xxx command works as expected: go build -o ./lark-cli . && go test ./tests/cli_e2e/base -run TestBase_FormQuestionsCreateDryRunAttachmentFileTypes -count=1

Related Issues

Summary by CodeRabbit

  • New Features

    • CLI now normalizes attachment-type form questions: when file types are omitted, they default to ["all"] and explicitly provided file types are preserved.
  • Tests

    • Added unit and end-to-end tests validating attachment question creation and dry-run output, ensuring default file type behavior.
  • Documentation

    • Updated examples and flag docs to describe attachment question shape and the default file type behavior.

Review Change Stack

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 17, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b2931c9e-da86-4faa-b16c-8820df9a5227

📥 Commits

Reviewing files that changed from the base of the PR and between 6f7f968 and a8bd24a.

📒 Files selected for processing (4)
  • shortcuts/base/base_form_execute_test.go
  • shortcuts/base/base_form_questions_create.go
  • skills/lark-base/references/lark-base-form-questions-create.md
  • tests/cli_e2e/base/base_form_questions_dryrun_test.go
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-base/references/lark-base-form-questions-create.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/cli_e2e/base/base_form_questions_dryrun_test.go
  • shortcuts/base/base_form_execute_test.go
  • shortcuts/base/base_form_questions_create.go

📝 Walkthrough

Walkthrough

Adds parsing and normalization so attachment questions created via --questions default attachment.file_types to ["all"] when omitted; updates DryRun/Execute to use the helper, extends docs with an example, and adds unit and e2e tests validating the behavior.

Changes

Attachment File Types Default Normalization

Layer / File(s) Summary
Parsing and normalization helpers
shortcuts/base/base_form_questions_create.go
parseFormQuestions unmarshals --questions and normalizeFormQuestionAttachments ensures attachment.file_types defaults to ["all"]. DryRun and Execute now use the shared parsing logic and updated flag help text.
Documentation and examples
skills/lark-base/references/lark-base-form-questions-create.md
Adds a +form-questions-create example with a required attachment question and documents that attachment.file_types defaults to ["all"] when omitted.
Unit test refactoring and attachment assertions
shortcuts/base/base_form_execute_test.go
Captures the create HTTP stub for request inspection and adds two t.Run subtests asserting defaulting to ["all"] and preserving explicit attachment.file_types.
E2E dry-run test for attachment defaults
tests/cli_e2e/base/base_form_questions_dryrun_test.go
Adds TestBase_FormQuestionsCreateDryRunAttachmentFileTypes to run --dry-run and assert the generated request contains attachment.file_types[0] == "all".

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • tengchengwei

Poem

🐰 I hopped into CLI fields with care,
Where attachments now accept all fare,
No longer bound to image-only night,
PDFs and docs can now take flight.
A gentle default—“all”—sets files right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: enabling attachment questions in base forms to accept all file types by default, addressing the core issue.
Description check ✅ Passed The PR description follows the repository template with all required sections: Summary, Changes, Test Plan (with checkboxes marked), and Related Issues linking to #929.
Linked Issues check ✅ Passed The PR fully addresses issue #929 requirements: normalizes missing/null attachment.file_types to ["all"], preserves explicit file_types values, includes normalized body in dry-run output, and documents the behavior.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #929: attachment question file type normalization in base_form_questions_create.go, corresponding tests, and documentation updates. No unrelated modifications detected.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 domain/base PR touches the base domain size/M Single-domain feat or fix with limited business impact labels May 17, 2026
@KhanCold
Copy link
Copy Markdown
Contributor

Hey @LawyerLyu, thanks for the fix! The same normalization is also needed in +form-questions-update (base_form_questions_update.go) — I spotted it earlier and submitted #945 as a follow-up, but closed it to avoid duplicating review effort. Happy to reopen or help integrate the update path here if you'd like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/base PR touches the base domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

form-questions-create: attachment 默认只接收图片,缺少文件类型配置参数

3 participants