Deleting an API can leave a listing on an API Portal when a publish records its row after the last unpublish pass

Abierto
#4,357 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go, sql
Área
api, backend

Línea de trabajo

Start by reading the UnpublishEverywhere, Publish, and withdrawIfArtifactDeleted paths from PR #4317, then trace the artifact schema and migrations for each SQL dialect. Add a regression test for the stated ordering and check that a publish during deletion is refused or withdrawn and that a failed delete clears the marker. Done means the deleted API's portal listing is withdrawn and the API can be published again after a failed delete.

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

Descripción

Type/Bug

Problem

Deleting an API first unpublishes it from every API Portal it is live on (UnpublishEverywhere, #4317), and only then removes the artifact, which cascades its api_publications rows away. Publish takes no lock shared with the delete: it pushes the listing to the portal, then records its row.

#4317 covers two orderings:

  • a publish whose row lands while the delete is unpublishing is caught by a later pass (up to 3 passes);
  • a publish that cannot record its row because the API is already gone withdraws its own listing (withdrawIfArtifactDeleted).

One ordering is still open:

  1. The delete's last pass reads the publications.
  2. A concurrent Publish pushes to a portal and records its row.
  3. The delete removes the artifact, and the cascade removes that new row.

The portal keeps serving the deleted API, and no row is left to unpublish it from. CodeRabbit raised this on #4317 (thread).

Proposed fix

Mark the API as being deleted before the unpublish passes, and make Publish's record step fail atomically when the API is marked. For example, promote the draft only while the artifact is not marked, in the same statement.

  • A publish recorded before the mark exists when the passes run, so it is unpublished.
  • A publish that tries to record after the mark fails, and withdrawIfArtifactDeleted (extended to the marked state) withdraws its listing.
  • A failed delete clears the mark.

This needs a nullable or defaulted marker on the artifact. It is an additive schema change, applied to every dialect with its ALTER TABLE. Holding a row lock across the portal HTTP calls instead would keep a database lock open during network I/O, so it is not preferred.

Done when

  • A test reproduces the ordering above (delete's last read, then publish records, then artifact removal) and the listing is withdrawn.
  • A publish attempted while the API is being deleted is refused or withdrawn, and a delete that fails leaves the API publishable again.
Lenguaje dominante
Go
Estrellas
85
Forks
137
Merge medio
1 d 12 h
PR fusionados (30 d)
247

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

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 wso2/api-platform

Todos los issues de wso2/api-platform

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.