api: paths that are not valid UTF-8 come back changed in JSON

未关闭
#587 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@ThomasK33 已经在做这个了。

开始于 2026年11月6日。

  • #729 来自 @ThomasK33 —— 未关闭

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
go, json

调研方向

The issue identifies Go's encoding/json behavior and says every endpoint that returns paths is affected, but it names no files or tests. Start by locating the API path fields and their JSON serialization, then review the open linked pull request #729 and its discussion. Done means agreeing on a wire format for non-UTF-8 paths, documenting it, and ensuring clients can round-trip the original path bytes.

由索引模型根据 Issue 内容生成。

描述

Problem

A tree entry name may hold bytes that are not valid UTF-8 (git accepts any byte except NUL and /). The API returns such a path changed: Go's encoding/json writes each invalid byte as U+FFFD, so a<0xff>b comes back as "a\ufffdb". A client cannot send that path back (for example in grep paths, file?path=, blame?path=), because it no longer names the file. This affects every endpoint that returns paths. Main has the same behavior.

The grep cursor is not affected: it base64-encodes the raw path bytes, so paging still works.

Found

By the clean-context advisor on PR #585 (#583, newline paths in grep), 2026-10-28. The advisor checked the encoding/json behavior. I did not call the API with such a path.

Possible fix

Decide on a wire form for non-UTF-8 paths (for example, an extra base64 field next to path, as some git hosting APIs do), and document it. This is an API design decision.

Trigger

A user report of a path that cannot be read back, or the next API change that adds a path field.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

主要语言
Go
星标
0
派生
0
平均合并
6 小时 16 分钟
30 天内合并 PR
243

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

coder/openstorage 的其他 Issue

查看 coder/openstorage 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。