Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Python: FileSessionStore.set fails on Windows for long session IDs because its temp file name is 38 characters longer than the snapshot

Ouverte Adaptée aux débutants
#9,682 0 commentaires 0 réactions 2 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@Sonica-B y travaille déjà.

Depuis le 26/10/2026.

  • #9739 par @chengwudi1 — ouverte

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
78/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python

Piste de recherche

Lisez FileSessionStore.set() et _session_file_path() dans le stockage de sessions Python, puis examinez tests/core/test_sessions.py, en particulier TestFileSessionStore::test_opaque_session_id_round_trips_through_safe_filename. Reproduisez l’échec lié aux chemins longs sous Windows décrit dans l’issue et comparez le nommage du fichier temporaire utilisé par FileCheckpointStorage et _filesystem._atomic_write_text. Le travail est terminé lorsqu’un test de régression confirme que le nom temporaire est indépendant de l’ID de session et que la session est enregistrée lorsque les chemins longs sont désactivés.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

python ready-for-implementation

FileSessionStore.set() writes each snapshot through a sibling temp file named .<snapshot name>.<uuid hex>.tmp, which is 38 characters longer than the snapshot file. On Windows with long paths disabled (the default, LongPathsEnabled = 0), a session ID at MAX_SESSION_ID_LENGTH (128) whose snapshot path fits under the 260-character limit can still fail to save, because the temp path does not fit.

This shows up as a failing unit test on my Windows 11 machine: tests/core/test_sessions.py::TestFileSessionStore::test_opaque_session_id_round_trips_through_safe_filename[xxx...x-False] fails with FileNotFoundError on the .tmp path. CI on windows-latest passes, I believe because GitHub's Windows runners enable long paths.

Minimal repro (Windows, long paths off, agent-framework-core at 67ba500):

import asyncio, tempfile
from pathlib import Path
from agent_framework import AgentSession, FileSessionStore

async def main():
    base = Path(tempfile.mkdtemp())
    sid = "x" * FileSessionStore.MAX_SESSION_ID_LENGTH
    storage = base / ("d" * (240 - (len(str(base)) + 1 + len(sid) + 5) - 1))
    store = FileSessionStore(storage)
    print(len(str(store._session_file_path(sid))))  # 240: the snapshot path itself fits
    await store.set(sid, AgentSession(session_id="s"))  # FileNotFoundError on the .tmp path

asyncio.run(main())

Expected: the session saves, since its snapshot path is under the limit. Actual: FileNotFoundError: [Errno 2] No such file or directory: '...\.xxx...x.json.<uuid>.tmp'.

Environment: Windows 11, Python 3.11.9, agent-framework-core 1.23.0 from main.

Proposed fix: name the temp file .maf-session-<uuid hex>.tmp, independent of the session ID, the way FileCheckpointStorage (.maf-ckpt-<uuid>.tmp) and _filesystem._atomic_write_text (.maf-state-<uuid>.tmp) already do, plus a regression test that checks the temp name does not grow with the ID. I have this ready and would like to open the PR if the direction is fine.

AI assistance: an AI coding assistant helped find the cause and draft this issue; the failing test and the repro above were run on my Windows 11 machine.

Langage dominant
Python
Étoiles
14.3k
Forks
2.5k
Merge moyen
2 j 15 h
PR mergées (30 j)
370

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de microsoft/agent-framework

Toutes les issues de microsoft/agent-framework

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.