Skip to content

Eliminate guaranteed HTTP 500 routes: dead history feature & Sensio Entity (#534)#547

Open
maltehuebner wants to merge 1 commit into
mainfrom
fix/dead-500-routes-534
Open

Eliminate guaranteed HTTP 500 routes: dead history feature & Sensio Entity (#534)#547
maltehuebner wants to merge 1 commit into
mainfrom
fix/dead-500-routes-534

Conversation

@maltehuebner

Copy link
Copy Markdown
Contributor

Summary

Audited against current main. Most routes from the issue were already fixed by the earlier Elasticsearch/Analysis cleanup: src/Air/Analysis/* and AnalysisController no longer exist, so /komfortofen, /analysis/silvester and /{stationCode}/limits are gone. Two guaranteed-500 problems remained; this PR resolves both.

Changes

1. POST /api/{citySlug} — SensioFrameworkExtraBundle not installed

CityApiController::postCityAction used #[Entity('city', expr: 'repository.findOneBySlug(citySlug)')] from SensioFrameworkExtraBundle, which is not installed, so the City argument could never be resolved (500 on every call). Replaced with #[MapEntity(expr: 'repository.findOneBySlug(citySlug)')] (exactly the pattern StationApiController::postStationAction already uses) and removed the dead use Sensio\...\Entity import.

2. GET /{stationCode}/history — non-functional dead code

StationController::historyAction relied on HistoryDataFactory, which references:

  • a $dataList property that exists nowhere in the class hierarchy,
  • a non-existent class App\Util\DateTimeUtil,
  • DataRetrieverInterface::retrieveDataForCoord() called with 4 args (interface declares 1).

This has never been runnable. The station_history flagception flag already defaulted to false, so the feature was effectively off. Removed it in full: route, controller action, HistoryDataFactory + HistoryDataFactoryInterface, templates/Station/history.html.twig, the station-page link, and the flag.

Cleanup

  • Deleted the corresponding phpstan-baseline.neon entries (baseline shrinks: $dataList, DateTimeUtil::getHourStartDateTime, the 4-param retrieveDataForCoord, HistoryDataFactoryInterface::setStation, the Sensio Entity attribute).
  • Removed the unused Elasticsearch container from docker-compose.yml, and the stale "Elasticsearch for search" references in CLAUDE.md / README.md — the app queries PostGIS directly and no longer uses Elastica.

Deliberately not implemented

Verification

  • vendor/bin/phpstan analyse — No errors (baseline updated).
  • vendor/bin/phpunit --testsuite="Project Test Suite" — 121 tests green.
  • bin/console lint:container --env=prod — OK.
  • bin/console debug:router --env=prodstation_history route gone; api_city_post still registered.
  • bin/console lint:twig — station template valid.

Note: full runtime verification of POST /api/{citySlug} needs a populated PostGIS DB (not available here); the fix mirrors the working postStationAction resolver.

Closes #534

🤖 Generated with Claude Code

…io Entity)

Most of the routes listed in the issue were already fixed on main by the
Elasticsearch/Analysis cleanup (src/Air/Analysis and AnalysisController no
longer exist). Two guaranteed-500 problems remained:

1) POST /api/{citySlug} (CityApiController::postCityAction) relied on
   #[Entity('city', expr: ...)] from SensioFrameworkExtraBundle, which is
   not installed, so the City argument could not be resolved -> 500.
   Replaced with #[MapEntity(expr: 'repository.findOneBySlug(citySlug)')],
   matching StationApiController::postStationAction. Removed the dead
   `use Sensio\...\Entity` import.

2) GET /{stationCode}/history (StationController::historyAction) used
   App\Air\PollutionDataFactory\HistoryDataFactory, which references a
   `$dataList` property that exists nowhere in the hierarchy, a
   non-existent class App\Util\DateTimeUtil, and calls
   DataRetrieverInterface::retrieveDataForCoord() with 4 args (interface
   declares 1). This code has never been runnable. As the flagception flag
   `station_history` already defaulted to false (feature effectively off),
   the broken feature was removed entirely: route, controller action,
   HistoryDataFactory + HistoryDataFactoryInterface, the history template,
   the station-page link, and the flag.

Removed the corresponding phpstan-baseline.neon entries (baseline shrinks).

Also removed the now-unused Elasticsearch container from docker-compose.yml
and the stale "Elasticsearch for search" references in CLAUDE.md and
README.md; the app queries PostGIS directly and no longer uses Elastica.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

[Kritisch] Sechs Routen liefern garantiert HTTP 500: Referenzen auf entfernte/nie existierende Klassen (Elastica, DateTimeUtil, Sensio)

1 participant