FileArtifactService changes CRLF and CR line endings in text artifacts
メンテナーはふだん 4 日以内に返信
@sanketpatil06 がすでに取り組んでいます。
2026年11月2日 から。
評価
調査の方向性
google/adk/artifacts/file_artifact_service.pyから始めて、テキストがどのように保存・読み込みされるかを追ってください。issueの再現スクリプトには、確認すべき改行のケースが示されています。そのスクリプトを実行し、ファイルベースのアーティファクトが、CRLFおよび単独のCRの行末を含め、保存したテキストを変更せずに返すことを確認してください。
索引モデルが issue の本文から書いたものです。
説明
🔴 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%)
- 主要言語
- Python
- スター
- 22.1k
- フォーク
- 4.3k
- 平均マージ
- 1日 10時間
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
google/adk-python のほかの issue
-
[LiteLLM] role='tool_responses' for Gemma 4 breaks tool calling on Vertex AI Model Garden MaaS (400 INVALID_ARGUMENT)対応中かも @surajksharma07 が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
google/adk-python#7977 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 4 日以内に返信
-
ContainerCodeExecutor drops output files that are hard links対応中かも @llalitkumarrr が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
google/adk-python#7906 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 4 日以内に返信
-
GCS skill loaders ignore a skill.md manifest that the local and zip loaders accept対応中かも @surajksharma07 が 6 日前に担当しました。 オープンtools
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
google/adk-python#7842 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 4 日以内に返信
-
RestApiTool crashes on a request body media type that has no schema対応中かも @llalitkumarrr が 6 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
google/adk-python#7838 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 4 日以内に返信
-
LiteLlm with SSE streaming records the answer twice in gen_ai.output.messages対応中かも @surajksharma07 が 14 日前に担当しました。 オープンmodels
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
google/adk-python#7630 · コメント 11 件 · 担当者 1 名 ·
メンテナーはふだん 4 日以内に返信
google/adk-python の issue をすべて見る
似ている issue
-
fuzz fuzz-unconfirmed
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
ready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
neilsh/stunt-reel#220 ·
メンテナーはふだん 1 日以内に返信
-
[Issue]: use_fp4_cache is accepted but ignored; the launcher always writes FP8 records対応中かも @0z5a が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
area: cli priority: p3 size: S type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
finos/open-resource-broker#757 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 6 日以内に返信