Skip to content

Bug: cleanupCollection deletes pre-existing resources #9

@thegagne

Description

@thegagne

Location: pkg/validator/validator.go:216-256

cleanupCollection runs twice per validation run — once as Global Setup (line 149) and once as Global Teardown (line 209). Each time, it:

  1. Lists all resources currently in the collection via paginated GET
  2. Issues a DELETE for every resource it finds

There is no tracking of which resources were created by the validator. It simply deletes everything it finds in the collection, including resources that existed before the validator ran.

The specific scenario that triggers data loss

  1. User has pre-existing data in their collection
  2. They run aep-e2e-validator against that collection
  3. Global Setup fires cleanupCollection → all pre-existing resources are deleted
  4. Tests run, creating their own resources
  5. Global Teardown fires cleanupCollection → test-created resources are deleted

The data loss happens at step 3 (Global Setup), before any tests even run.

The intent was probably to ensure a clean slate before/after tests so results are deterministic. But the implementation assumes it owns the entire collection, which is unsafe if the user points the validator at a collection that has existing data.

Suggested fix (for the issue description)

The validator should either:

  • Track created resources and only delete those during cleanup (safest), or
  • Warn users prominently in docs that cleanupCollection will delete all data in the targeted collection, or
  • Require a dedicated/empty collection and fail fast if resources already exist at Global Setup time rather than silently deleting them

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions