Skip to content

[core] Fix orphaned parking deletion when parent stop place is missing - #433

Open
teppope wants to merge 3 commits into
entur:masterfrom
tmfg:fix/parking-orphan-auth-fallback
Open

[core] Fix orphaned parking deletion when parent stop place is missing#433
teppope wants to merge 3 commits into
entur:masterfrom
tmfg:fix/parking-orphan-auth-fallback

Conversation

@teppope

@teppope teppope commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes a bug where a parking whose parent stop place has already been deleted could never be deleted (or edited) again, permanently blocking cleanup of such orphaned parkings.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Issue

When checking authorization for editing or deleting a Parking, Tiamat always resolves the request to the parking's parent StopPlace first (TiamatEntityResolver.resolveCorrectEntity). If the parent stop place no longer exists (e.g. it was deleted without first deleting its child parking), this resolution step threw an IllegalArgumentException instead of falling back to checking permission on the parking itself - so any attempt to edit or delete the orphaned parking failed outright.

This surfaced via an orphan-cleanup end-to-end test that found a leftover parking in a downstream environment whose parent stop place no longer existed; the delete mutation failed with "Parking does not have a parent site ref that points to a stop place."

The fix makes the existing fallback path actually reachable: when the parent stop place cannot be found, permission is checked against the parking itself, the same fallback already used when a parking has no parentSiteRef at all. Normal-case behaviour (parent stop place exists) is unchanged. ParkingDeleter was simplified to rely on this shared resolver instead of duplicating parent-resolution logic locally, matching the pattern already used by ParkingUpdater.

Note: this fix addresses the inability to clean up an already-orphaned parking. It does not change how orphans are created in the first place (i.e. StopPlaceDeleter still does not check for or cascade to child parkings) - that is being tracked as a separate follow-up.

Unit tests

  • Added TiamatEntityResolverTest (new, no prior test existed for this class): covers a parking resolving to its parent stop place, falling back to itself when the parent no longer exists, and falling back to itself when there is no parent at all.
  • Extended ParkingDeleterTest with deleteParkingWithUnresolvableParent and deleteParkingWithNoParentSiteRef, both asserting the parking can now be deleted successfully.
  • All three test classes pass locally (mvn test -Dtest=ParkingDeleterTest,TiamatEntityResolverTest).

@teppope teppope changed the title Fix orphaned parkings blocking deletion when parent stop place no longer exists [core] Fix orphaned parking deletion when parent stop place is missing Jul 28, 2026
@teppope
teppope marked this pull request as ready for review July 28, 2026 12:01
@teppope

teppope commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

Restored WARN logging

@teppope
teppope requested a review from testower July 31, 2026 08:48
teppope and others added 3 commits September 3, 2026 14:41
…ger exists

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@teppope
teppope force-pushed the fix/parking-orphan-auth-fallback branch from fa77806 to a512afa Compare September 3, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant