Skip to content

Approval attachment uploads lose filename and show as unknown file #729

@rendylong

Description

@rendylong

Summary

When creating a Feishu/Lark approval instance with an attachmentV2 widget, files uploaded through lark-cli api POST /open-apis/approval/v4/files/upload are accepted and can be attached to the approval, but the approval UI displays them as unknown file because the original filename/extension is not preserved in the created approval instance.

There is also a mismatch between instances/preview and instances:

  • instances/preview accepts object-shaped attachmentV2.value entries that include code, name, and type.
  • instances rejects the same object-shaped values with Widget value is not string.

This makes it hard for agents/scripts to create approval instances with user-friendly attachment names.

Environment

  • lark-cli version 1.0.22
  • macOS
  • Command path: lark-cli api ...
  • Approval API: /open-apis/approval/v4/files/upload, /open-apis/approval/v4/instances/preview, /open-apis/approval/v4/instances

Reproduction

  1. Upload a PDF attachment and include name and type in multipart form fields:
lark-cli api POST /open-apis/approval/v4/files/upload \
  --as bot \
  --file path/to/invoice.pdf \
  --data '{"type":"attachment","name":"invoice.pdf"}' \
  --format json

The upload succeeds and returns a file code.

  1. Use the returned code in an approval attachmentV2 widget:
{
  "id": "widget_attachment",
  "type": "attachmentV2",
  "value": ["<uploaded-file-code>"]
}
  1. Create the approval instance:
lark-cli api POST /open-apis/approval/v4/instances \
  --as bot \
  --data - \
  --format json < approval_request.json

The instance is created successfully, but the approval UI shows the attachment as unknown file instead of invoice.pdf.

Preview vs Create Mismatch

The preview endpoint accepts object-shaped values:

{
  "id": "widget_attachment",
  "type": "attachmentV2",
  "value": [
    {
      "code": "<uploaded-file-code>",
      "name": "invoice.pdf",
      "type": "attachment"
    }
  ]
}

This request succeeds against:

lark-cli api POST /open-apis/approval/v4/instances/preview --as bot --data -

But the create endpoint rejects the same payload:

lark-cli api POST /open-apis/approval/v4/instances --as bot --data -

Error:

Widget value is not string. index= 5, widget type= attachmentV2.

Expected Behavior

One of the following would make the workflow reliable:

  1. files/upload preserves the uploaded filename/extension so approval UI displays invoice.pdf instead of unknown file.
  2. instances accepts the same object-shaped attachmentV2.value that instances/preview accepts, including name and type.
  3. lark-cli documents the limitation and provides a recommended way to create approval attachments with visible filenames.

Actual Behavior

  • Uploaded attachments can be attached to approval instances.
  • Approval UI displays the attachment as unknown file.
  • Supplying a filename in files/upload --data '{"name":"..."}' does not appear to affect the displayed filename.
  • Supplying object-shaped attachment values passes preview but fails create.

Workaround

For image-like attachments, converting a PDF to PNG and uploading it as type=image avoids the worst UX because the image is previewable, but this is not a good replacement for preserving the original filename for PDFs and other documents.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions