FileComment model includes is_whole/quote fields but they are silently ignored when creating comments on docx files
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với model file_comment.py được tạo và FileCommentBuilder, sau đó tái hiện POST /open-apis/drive/v1/files/{file_token}/comments với file_type=docx bằng request được cung cấp. So sánh các trường của request với response List API nhận được và tài liệu chính thức “Add a Global Comment”. Công việc được xem là hoàn tất khi giới hạn hoặc hành vi được hỗ trợ đã được giải quyết rõ ràng mà không âm thầm bỏ qua các trường.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
The FileComment model and its FileCommentBuilder expose is_whole and quote fields, suggesting that inline (non-whole-document) comments can be created via the API. However, when calling POST /open-apis/drive/v1/files/{file_token}/comments with file_type=docx, these fields are silently ignored — the API always creates a global (whole-document) comment regardless of the values passed.
Steps to Reproduce
import httpx
body = {
"is_whole": False,
"quote": "目标是验证文档导入与结构化展示", # exact text from the document
"reply_list": {
"replies": [{
"content": {
"elements": [
{"type": "text_run", "text_run": {"text": "This should be an inline comment"}}
]
}
}]
}
}
resp = httpx.post(
"https://open.larksuite.com/open-apis/drive/v1/files/{file_token}/comments",
headers={"Authorization": f"Bearer {tenant_access_token}"},
params={"file_type": "docx"},
json=body,
timeout=15,
)
Expected Behavior
The comment should be created as an inline comment anchored to the quoted text, with is_whole=False in the response.
Actual Behavior
The API returns code: 0 (success), but when retrieving the comment via the List API:
{
"comment_id": "...",
"is_whole": true,
"quote": "",
...
}
The comment is always a global comment (is_whole=true, quote=""), no matter what is_whole or quote values are sent in the request.
Test Details
Tested with 5 different quote values against a real docx document:
| quote value | Result |
|---|---|
| Exact substring with punctuation | is_whole=true, quote="" |
| Full sentence from document | is_whole=true, quote="" |
| Partial text match | is_whole=true, quote="" |
| Heading text | is_whole=true, quote="" |
| Empty (no quote) | is_whole=true, quote="" |
All 5 comments were created as global comments.
The Problem
The SDK's auto-generated FileComment model uses the same class for both request and response, so it exposes builder methods for is_whole() and quote():
# file_comment.py (auto-generated)
class FileCommentBuilder(object):
def is_whole(self, is_whole: bool) -> "FileCommentBuilder":
self._file_comment.is_whole = is_whole
return self
def quote(self, quote: str) -> "FileCommentBuilder":
self._file_comment.quote = quote
return self
This is misleading because:
- Developers assume these fields are functional for creation since the builder exposes them
- The API accepts the request without any error or warning — it just silently ignores the fields
- The official documentation page is titled "Add a Global Comment" but this isn't obvious when using the SDK
Suggestion
One or more of the following would help:
- Document the limitation — Clarify in the API docs that
is_wholeandquoteare response-only fields, not accepted in the create request body fordocxfiles - Separate request/response models — Use a dedicated
CreateFileCommentRequestBodythat only includesreply_list, instead of reusingFileComment - Support inline comments — If this is a missing feature, it would be very useful to support creating inline comments via the API (the UI already supports this)
- Return an error — If
is_whole=Falseorquoteis passed but not supported, return an error code instead of silently ignoring
Environment
- SDK version: latest (
lark-oapifrom PyPI) - API base:
https://open.larksuite.com/open-apis - Document type:
docx(New Doc) - Auth:
tenant_access_token
- Ngôn ngữ chính
- Python
- Star
- 559
- Fork
- 102
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của larksuite/oapi-sdk-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
larksuite/oapi-sdk-python#163 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
larksuite/oapi-sdk-python#162 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 94/100
larksuite/oapi-sdk-python#161 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
larksuite/oapi-sdk-python#160 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
larksuite/oapi-sdk-python#159 ·
Tất cả issue của larksuite/oapi-sdk-python
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
zostera/django-bootstrap4#894 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
use-agent-os/agent-os#3276 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NousResearch/hermes-agent#117848 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
zilliztech/memsearch#759 ·