FileArtifactService changes CRLF and CR line endings in text artifacts
Maintainer thường phản hồi trong vòng 4 ngày
@sanketpatil06 đang làm issue này rồi.
Từ ngày 2/11/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
Hướng nghiên cứu
Bắt đầu với google/adk/artifacts/file_artifact_service.py và theo dõi cách văn bản được lưu và tải; tập lệnh tái hiện issue cho biết các trường hợp xuống dòng cần kiểm tra. Chạy tập lệnh đó, sau đó xác minh rằng các artifact dựa trên tệp trả về nguyên vẹn văn bản đã lưu, bao gồm cả các kiểu kết thúc dòng CRLF và CR đơn lẻ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🔴 Required Information
Describe the Bug:
FileArtifactService changes the line endings of text artifacts. A text artifact containing \r\n or a lone \r loads back with \n in their place. The payload is read with Path.read_text, whose universal newline mode rewrites both. It is written with Path.write_text, which translates \n to os.linesep, so on Windows every \n is stored as \r\n.
InMemoryArtifactService and GcsArtifactService return the saved text unchanged, so the same artifact differs only on the file backend. That backend is what adk web and adk run use by default (use_local_storage=True, via create_local_artifact_service). CSV files (RFC 4180 uses CRLF), patches, and Windows-authored text a tool saves therefore load back different from what was saved.
Steps to Reproduce:
pip install google-adk(reproduced onmainat 8cd3b12c8)- Run:
import asyncio, tempfile
from google.genai import types
from google.adk.artifacts.file_artifact_service import FileArtifactService
from google.adk.artifacts.in_memory_artifact_service import InMemoryArtifactService
async def main():
text = "id,name\r\n1,a\r\n2,b\rc\n"
for svc in (FileArtifactService(root_dir=tempfile.mkdtemp()), InMemoryArtifactService()):
await svc.save_artifact(app_name="a", user_id="u", session_id="s",
filename="t.csv", artifact=types.Part(text=text))
got = await svc.load_artifact(app_name="a", user_id="u", session_id="s",
filename="t.csv")
print(type(svc).__name__, repr(got.text), got.text == text)
asyncio.run(main())
Expected Behavior:
Both services return the saved text unchanged.
Observed Behavior:
FileArtifactService 'id,name\n1,a\n2,b\nc\n' False
InMemoryArtifactService 'id,name\r\n1,a\r\n2,b\rc\n' True
Environment Details:
- ADK Library Version (pip show google-adk): 2.13.0 (main at 8cd3b12c8)
- Desktop OS: macOS (the read-side rewrite is platform independent; the write-side translation affects Windows)
- Python Version (python -V): 3.11
Model Information:
- Are you using LiteLLM: No
- Which model is being used: N/A (artifact service only)
🟡 Optional Information
Regression:
Not that I know of. The file backend has read and written text payloads with read_text / write_text.
Additional Context:
I would like to contribute a focused fix for this. Would writing artifact.text.encode("utf-8") with write_bytes and decoding read_bytes() on load be an acceptable approach? This keeps the stored payload exactly equal to the saved text. The error handling stays the same (OSError / UnicodeDecodeError are still caught and logged). Metadata JSON reads and writes are unaffected, since JSON escapes CR/LF inside strings.
How often has this issue occurred?:
- Always (100%)
- Ngôn ngữ chính
- Python
- Star
- 22.1k
- Fork
- 4.3k
- Merge trung bình
- 1 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
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 google/adk-python
-
Regression of #3977 / #4054: `adk create` accepts hyphens in agent names, agent then fails to loadĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
google/adk-python#8002 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
ContainerCodeExecutor drops output files that are hard linksCó thể đã có người làm @llalitkumarrr đã nhận 4 ngày trước. Đang mởcore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
google/adk-python#7906 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 4 ngày
-
GCS skill loaders ignore a skill.md manifest that the local and zip loaders acceptCó thể đã có người làm @surajksharma07 đã nhận 7 ngày trước. Đang mởtools
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
google/adk-python#7842 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 4 ngày
-
RestApiTool crashes on a request body media type that has no schemaCó thể đã có người làm @llalitkumarrr đã nhận 7 ngày trước. Đang mởcore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
google/adk-python#7838 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 4 ngày
-
LiteLlm with SSE streaming records the answer twice in gen_ai.output.messagesCó thể đã có người làm @surajksharma07 đã nhận 15 ngày trước. Đang mởmodels
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
google/adk-python#7630 · 11 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của google/adk-python
Issue tương tự
-
[MOVIE]: Airport '77 (1977)Đang mởrequest-theme
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
LizardByte/ThemerrDB#9883 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Project-MONAI/MONAI#9258 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
catalog:deprecation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
surendranb/free-inference#31 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
fritzprix/libr-agent#2612 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage presubmit-gate
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
gke-labs/kube-agents#5001 ·
Maintainer thường phản hồi trong vòng 1 ngày