Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

settings/map returns 500: googleMapsApiKey() returns null for its string return type (no Google Maps key configured)

Aperta Adatta ai principianti
#337 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
90/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
api, backend

Direzione di ricerca

Inizia da Fleetbase\FleetOps\Http\Controllers\Internal\v1\SettingController::googleMapsApiKey() e dal suo punto di ingresso getMapSettings() per GET /int/v1/fleet-ops/settings/map. Riproduci il problema senza alcuna chiave Google Maps configurata, quindi verifica che l’endpoint restituisca 200 senza generare un TypeError e mantenga il comportamento con chiave vuota.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

Fleetbase\FleetOps\Http\Controllers\Internal\v1\SettingController::googleMapsApiKey() is declared with a string return type, but returns null when no Google Maps API key is configured:

protected function googleMapsApiKey(): string
{
    return config('services.google_maps.api_key', env('GOOGLE_MAPS_API_KEY', ''));
}

services.google_maps.api_key exists in the config (populated from env('GOOGLE_MAPS_API_KEY')), so when the variable is not set its value is null and the '' default is never used. PHP throws:

TypeError: Fleetbase\FleetOps\Http\Controllers\Internal\v1\SettingController::googleMapsApiKey(): Return value must be of type string, null returned

Impact

GET /int/v1/fleet-ops/settings/map (getMapSettings()) returns 500 for every organization. The console requests it when entering Fleet-Ops, so the Orders route fails ("Error while processing route: console.fleet-ops.operations.orders.index.index Server Error") and the UI stays on "Loading orders". Fleet-Ops is unusable on any install that uses Leaflet and has no Google Maps key, which is the default setup.

Versions

Fleetbase v0.7.63 (fleetops v0.6.68).

Reproduction

  1. Self-hosted install with no GOOGLE_MAPS_API_KEY and no Google Maps key saved in Admin → Settings → Services.
  2. Log in and open Fleet-Ops (or switch organization and open Fleet-Ops).
  3. GET /int/v1/fleet-ops/settings/map → 500; the orders view never loads.
config('services.google_maps.api_key');                 // null
app(SettingController::class)->getMapSettings();        // TypeError

Suggested fix

protected function googleMapsApiKey(): string
{
    return (string) (config('services.google_maps.api_key') ?? env('GOOGLE_MAPS_API_KEY', ''));
}

Workaround

Set GOOGLE_MAPS_API_KEY="(empty)" on the API container: Laravel reads it as an empty string and the endpoint returns 200.

Lingua principale
PHP
Stelle
36
Fork
69
Merge medio
1g 6h
PR unite (30g)
32

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di fleetbase/fleetops

Tutte le issue di fleetbase/fleetops

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.