Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Python: [Bug]: InMemoryAgentFileStore permits a path to be both a file and a directory

已关闭
#8,567 6 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@westey-m 已经在做这个了。

开始于 2026年9月21日。

评估

这个 Issue 还没有评估数据。

描述

harness python reproduced

Description

InMemoryAgentFileStore permits both Reports and Reports/q1.txt to exist. Consequently, list_children("") returns two entries named Reports, one reported as a file and one as a directory. A caller cannot tell which path to use, and this state cannot occur in FileSystemAgentFileStore.

This happens in either write order. write() checks only whether the exact file key exists; it does not reject a file ancestor or an existing descendant. Its case-insensitive key normalization means Reports and reports/q1.txt conflict as well.

Expected: Reject the second write without changing the existing content. A file path cannot also serve as a directory, regardless of casing.

Actual: Both writes succeed and the root listing contains a same-named file and directory.

Code Sample

import asyncio
from agent_framework import InMemoryAgentFileStore


async def main() -> None:
    store = InMemoryAgentFileStore()
    await store.write("Reports", "file")
    await store.write("Reports/q1.txt", "nested")
    print([(entry.name, entry.type) for entry in await store.list_children()])
    # [('Reports', 'directory'), ('Reports', 'file')]


asyncio.run(main())

The new regression test fails against the unmodified package (Failed: DID NOT RAISE NotADirectoryError) and passes against the local fix.

Error Messages / Stack Traces

None. The inconsistent state is accepted silently.

Package Versions

Source checkout at 999dda7970fe969c0901d524365ce34ecbda6227 (agent-framework-core version 1.18.0); the relevant write() implementation was also checked against the repository's current default branch on 2026-09-21. The public API reproduction and regression tests used this source checkout through an existing virtual environment, not a separately installed release package.

Python Version

Python 3.12.0 for the isolated source execution.

Additional Context

FileSystemAgentFileStore uses real filesystem paths, where a file cannot be the parent of another file and a nonempty directory cannot be replaced by a file. The in-memory store is used for tests and lightweight use, so matching this basic path invariant avoids testing a state the disk store cannot represent.

Local draft fix: reject a write if any ancestor is already a file or if the target path already has descendants. A focused regression test covers both write orders and verifies the existing content remains intact. The new test fails on the baseline and passes with the fix. The full test_harness_file_access.py file passes with the fix: 73 passed, 6 skipped. Ruff check, Ruff format check, py_compile, and git diff --check also pass. The reused virtual environment lacks pytest-timeout, causing an unrelated pytest configuration warning.

Searches of repository issues and PRs for InMemoryAgentFileStore conflict, file and directory same name, and file store path collision found no matching report or implementation on 2026-09-21.

主要语言
Python
星标
14.2k
派生
2.5k
平均合并
2 天 9 小时
30 天内合并 PR
384

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

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

microsoft/agent-framework 的其他 Issue

查看 microsoft/agent-framework 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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