Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

InMemorySessionService.appendEvent recreates a deleted session

Abierto Apto para principiantes
#1,697 2 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@hirematha ya está trabajando en esto.

Desde el 26/10/2026.

  • #1698 de @DisturbedCrow — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java
Área
backend, database

Línea de trabajo

Empieza en InMemorySessionService.appendEvent y examina la búsqueda y la inserción en el mapa de sesiones que se muestran en el issue. Lee el caso de prueba específico InMemorySessionServiceTest y compara el comportamiento de Python ADK mencionado en el informe. Se considera terminado cuando añadir un evento con una referencia conservada después de la eliminación lanza SessionNotFoundException y getSession sigue devolviendo null.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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%)
Lenguaje dominante
Java
Estrellas
1.8k
Forks
440
Merge medio
3 d 16 h
PR fusionados (30 d)
92

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de google/adk-java

Todos los issues de google/adk-java

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.