Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions internal/http/system_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ func (h *SystemConfigsHandler) handleList(w http.ResponseWriter, r *http.Request
}

func (h *SystemConfigsHandler) handleGet(w http.ResponseWriter, r *http.Request) {
locale := extractLocale(r)
key := r.PathValue("key")
val, err := h.store.Get(r.Context(), key)
if err != nil {
writeJSON(w, http.StatusNotFound, map[string]string{"error": i18n.T(locale, i18n.MsgNotFound, "config", key)})
return
// Fail-soft: settings-store "missing" = "empty". Returning 200 here
// stops Chrome from logging 404s for polled alert-state keys
// (e.g. alert.background.provider_error) that legitimately don't
// exist most of the time. Frontend treats empty as "no alert".
val = ""
}
writeJSON(w, http.StatusOK, map[string]string{"key": key, "value": val})
}
Expand Down
17 changes: 11 additions & 6 deletions ui/web/src/lib/timezone-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,17 @@ export function getAllIanaTimezones(): TzOption[] {
return _cachedTimezones;
}

let _cachedTzSet: Set<string> | undefined;

/** Check if a value is a valid IANA timezone from the dynamic list. */
/** Validate via Intl directly — accepts canonical + deprecated aliases that
* the browser's tz database knows (e.g. Asia/Saigon ↔ Asia/Ho_Chi_Minh).
* The earlier Set-based check rejected names whose canonical form differed
* from the user's stored value across browser/OS combos.
*/
export function isValidIanaTimezone(tz: string): boolean {
if (!_cachedTzSet) {
_cachedTzSet = new Set(getAllIanaTimezones().map((t) => t.value));
if (!tz) return false;
try {
new Intl.DateTimeFormat("en-US", { timeZone: tz });
return true;
} catch {
return false;
}
return _cachedTzSet.has(tz);
}
Loading