Freika/dawarich · warning

[Settings] No API key available for recalculation status…

Error message

[Settings] No API key available for recalculation status check

What it means

The transportation-mode recalculation status poll needs the user's API key as a Bearer token. The Stimulus controller exposes it via apiKeyValue; when that value is blank the manager logs this warning and skips the fetch entirely, leaving the recalculation progress UI unupdated.

Solutions

  1. Generate an API key in the app's API keys settings if the user has none
  2. Ensure the map element renders data-maps--maplibre-api-key-value with the key (check the DOM)
  3. If the status UI must work without a key, expose recalculation status through a session-authenticated route instead of the API-key endpoint
  4. Treat as expected when keyless — downgrade to debug and render a neutral state

Example fix

// before
const apiKey = this.controller.apiKeyValue
if (!apiKey) {
  console.warn("[Settings] No API key available for recalculation status check")
  return
}
// after
const apiKey = this.controller.apiKeyValue
if (!apiKey) {
  console.debug("[Settings] No API key; skipping recalculation status poll")
  this.updateRecalculationUI({ status: "unknown" }) // neutral UI instead of stale UI
  return
}
Defensive patterns

Strategy: validation

Validate before calling

const key = this.controller.apiKeyValue
if (typeof key !== "string" || key.trim().length === 0) {
  this.updateRecalculationUI({ status: "unknown" })
  return
}

Type guard

/** @param {unknown} v @returns {v is string} */
function isNonEmptyKey(v) {
  return typeof v === "string" && v.trim().length > 0
}

Prevention

When it happens

Trigger: The maps controller element lacks its api-key data attribute (anonymous view, template regression, value renamed in an upgrade); the attribute present but empty because the user never generated an API key; a shared or embedded map rendered without a key.

Common situations: Fresh installs where the user has not created an API key in settings; view refactors dropping the data attribute; controller value names changed between versions so old markup no longer populates apiKeyValue.

Understand the failure class

Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.

Related errors


AI-assisted analysis of Freika/dawarich@97fad417c5 (2026-08-21). Data as JSON: /api/errors/a8e8e3120e57ac4d. Report an issue: GitHub.

Appendix: source

Thrown at app/javascript/controllers/maps/maplibre/settings_manager.js:468

      this.setTransportationSettingsLocked(true)
      // Start polling for status updates
      this.startRecalculationPolling()
    } else {
      Toast.success(translate("messages.transportation_settings_saved"))
      this.resetTransportationDirtyState()
    }
  }

  // ===== Transportation Mode Recalculation Status =====

  /**
   * Check the transportation mode recalculation status
   */
  async checkRecalculationStatus() {
    try {
      const apiKey = this.controller.apiKeyValue
      if (!apiKey) {
        console.warn(
          "[Settings] No API key available for recalculation status check",
        )
        return
      }

      const response = await fetch(
        "/api/v1/settings/transportation_recalculation_status",
        {
          headers: {
            Authorization: `Bearer ${apiKey}`,
            "Content-Type": "application/json",
          },
        },
      )

      if (!response.ok) {
        console.warn(
          "[Settings] Failed to check recalculation status:",

View on GitHub (pinned to 97fad417c5)