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

InMemorySessionService.appendEvent recreates a deleted session

Ouverte Adaptée aux débutants
#1,697 2 commentaires 0 réactions 1 personne assignée Voir sur GitHub

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

@hirematha y travaille déjà.

Depuis le 26/10/2026.

  • #1698 par @DisturbedCrow — ouverte

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
84/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
java
Domaine
backend, database

Piste de recherche

Commencez par InMemorySessionService.appendEvent et examinez la recherche et l’insertion dans la map des sessions présentées dans l’issue. Lisez le cas de test ciblé InMemorySessionServiceTest et comparez le comportement de Python ADK mentionné dans le rapport. Le travail est terminé lorsque l’ajout avec une référence conservée après la suppression lève SessionNotFoundException et que getSession renvoie toujours null.

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

Description

needs review

🔴 Required Information

Describe the Bug:

InMemorySessionService.appendEvent can bring a deleted session back. If code keeps a reference to a Session, deletes it through the service, and then appends an event using the old reference, appendEvent inserts that session into the internal map again.

Steps to Reproduce:

  1. Create an InMemorySessionService and a session.
  2. Delete the session.
  3. Call appendEvent with the retained Session object.
  4. Fetch the deleted session again.

Expected Behavior:

The append should fail because the session no longer exists, and the session should remain deleted. SessionNotFoundException seems like the natural error here.

Observed Behavior:

The append succeeds, and getSession returns the previously deleted session again.

appendEvent currently ends with:

sessions
    .computeIfAbsent(appName, unused -> new ConcurrentHashMap<>())
    .computeIfAbsent(userId, unused -> new ConcurrentHashMap<>())
    .put(sessionId, session);

so all three missing levels are recreated.

Environment Details:

  • ADK Library Version: current main at 84bae34a9ae4c133c7e6294faff5cb50f64a3474
  • OS: Ubuntu 24.04
  • Java Version: OpenJDK 21.0.12.1

Model Information:

  • Which model is being used: N/A

🟡 Optional Information

Regression:

Unknown.

Logs:

I added the focused test below and ran:

./mvnw -pl core -Dtest=InMemorySessionServiceTest#appendEvent_afterDelete_doesNotRecreateSession test

It fails with:

expected com.google.adk.sessions.SessionNotFoundException to be thrown, but nothing was thrown
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

Screenshots / Video:

N/A

Additional Context:

The Python ADK InMemorySessionService.append_event checks that the session ID is present and raises SessionNotFoundError before applying the event. Matching that behavior would also prevent a stale session reference from undoing a successful deletion.

Minimal Reproduction Code:

@Test
public void appendEvent_afterDelete_doesNotRecreateSession() {
  InMemorySessionService sessionService = new InMemorySessionService();
  Session session = sessionService.createSession("app", "user").blockingGet();
  sessionService.deleteSession("app", "user", session.id()).blockingAwait();

  assertThrows(
      SessionNotFoundException.class,
      () -> sessionService.appendEvent(session, Event.builder().build()).blockingGet());

  assertThat(
          sessionService.getSession("app", "user", session.id(), Optional.empty()).blockingGet())
      .isNull();
}

How often has this issue occurred?:

  • Always (100%)
Langage dominant
Java
Étoiles
1.8k
Forks
440
Merge moyen
3 j 16 h
PR mergées (30 j)
92

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 google/adk-java

Toutes les issues de google/adk-java

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

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