fix(base): default attachment file_types to all for form-questions-update#945
Conversation
…date PR larksuite#931 fixed the same issue for +form-questions-create, but +form-questions-update still silently restricts attachment questions to images only when the user omits the attachment.file_types field. This change mirrors the create fix: when the --questions JSON contains an attachment type question without explicit file_types, normalize the payload so it defaults to ["all"], matching Feishu UI behavior. - Normalize attachment questions in Execute and DryRun. - Update flag description to document the attachment configuration. - Add unit tests for the normalization logic. Relates to larksuite#929 (PR larksuite#931 follow-up).
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds parsing and normalization logic for form question updates with special handling for attachment-type questions. A new helper function ensures attachment questions include a ChangesForm Questions Parsing and Normalization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches🧪 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.
Pull request overview
This PR updates the Base +form-questions-update shortcut to normalize attachment question payloads so missing/null attachment.file_types defaults to ["all"], aligning update behavior with Feishu UI expectations.
Changes:
- Parses
--questionsthrough a new normalization helper before executing the PATCH request. - Adds normalized request body output for dry-run.
- Adds unit tests for attachment normalization and invalid JSON parsing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
shortcuts/base/base_form_questions_update.go |
Adds update-question attachment normalization and dry-run body output. |
shortcuts/base/base_form_questions_update_test.go |
Adds unit tests for update-question attachment normalization behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| {Name: "table-id", Desc: "table ID", Required: true}, | ||
| {Name: "form-id", Desc: "form ID", Required: true}, | ||
| {Name: "questions", Desc: `questions JSON array, max 10 items, each item must include "id". Supported fields: "id"(required),"title","description"(plain text or markdown link like [text](https://example.com)),"required","option_display_mode"(0=dropdown,1=vertical,2=horizontal,select only). E.g. '[{"id":"q_001","title":"Updated?","required":true}]'`, Required: true}, | ||
| {Name: "questions", Desc: `questions JSON array, max 10 items, each item must include "id". Supported fields: "id"(required),"title","description"(plain text or markdown link like [text](https://example.com)),"required","option_display_mode"(0=dropdown,1=vertical,2=horizontal,select only),"attachment"({"file_types":["all"]},attachment only). E.g. '[{"id":"q_001","title":"Updated?","required":true}]'`, Required: true}, |
| if questions, err := parseUpdateFormQuestions(runtime.Str("questions")); err == nil { | ||
| dr.Body(map[string]interface{}{"questions": questions}) |
Fix
base +form-questions-updateattachment file_types defaultSummary
PR #931 fixed the same issue for
+form-questions-create, but+form-questions-updatestill silently restricts attachment questions to images only when the user omits theattachment.file_typesfield.This change mirrors the create fix: when the
--questionsJSON contains an attachment type question without explicitfile_types, normalize the payload so it defaults to["all"], matching Feishu UI behavior.Changes
attachment.file_typesto["all"]for attachment type questions.attachmentconfiguration field ({"file_types":["all"]}) in the--questionshelp text.Related
Checklist
Summary by CodeRabbit
New Features
Documentation
Tests