diegosouzapw/OmniRoute · error · Error

getErrorMessage(payload, tCommon("failedToLoad"))

Error message

getErrorMessage(payload, tCommon("failedToLoad"))

What it means

Helper-driven load failure: loadConfig() GETs /api/settings/payload-rules and, on a non-ok response, throws getErrorMessage(payload, tCommon('failedToLoad')) — the helper prefers a sanitized error field from the JSON body and falls back to the localized generic message. It means the payload rules YAML/JSON config was never loaded into the editor; the summary counts shown come from an empty source.

Solutions

  1. Check the GET response body for a sanitized error string identifying the cause
  2. Confirm the settings/payload-rules endpoint is registered and the session is authenticated
  3. Retry the load; the editor stays editable but saving an unverified config is unsafe
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/app/(dashboard)/dashboard/settings/components/PayloadRulesTab.tsx:98 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/8aabb54bf2222b49. Report an issue: GitHub.

Appendix: source

Thrown at src/app/(dashboard)/dashboard/settings/components/PayloadRulesTab.tsx:98

  const summary = useMemo(() => {
    const source = parsedEditor.value;
    return {
      default: getRuleSectionCount(source, ["default"]),
      override: getRuleSectionCount(source, ["override"]),
      filter: getRuleSectionCount(source, ["filter"]),
      defaultRaw: getRuleSectionCount(source, ["defaultRaw", "default-raw"]),
    };
  }, [parsedEditor.value]);

  const loadConfig = useCallback(async () => {
    setLoading(true);
    setMessage(null);
    try {
      const response = await fetch("/api/settings/payload-rules");
      const payload = await response.json();
      if (!response.ok) {
        throw new Error(getErrorMessage(payload, tCommon("failedToLoad")));
      }

      setEditorValue(JSON.stringify(payload, null, 2));
    } catch (error) {
      setMessage({
        type: "error",
        text: error instanceof Error ? error.message : tCommon("failedToLoad"),
      });
    } finally {
      setLoading(false);
    }
  }, [tCommon]);

  useEffect(() => {
    loadConfig();
  }, [loadConfig]);

  const handleReset = () => {

View on GitHub (pinned to a179ffed5b)