different-ai/openwork · error

app.unknown_error

app.unknown_error

Error message

t("app.unknown_error")

What it means

In EnvironmentVariableProvider the modify-env mutation requires an initialized OpenWork client. If the client object is null (the app runtime/connection has not been established), the mutation throws an error with the localized "app.unknown_error" message rather than making a call on a null object.

Source

Thrown at apps/app/src/react-app/domains/settings/pages/environment-variable-provider.tsx:140

    },
    onError: (error) => {
      toast.error(error.message);
    },
  });

  const markChangesPending = useCallback(() => {
    clearOpenworkEnvSystemContextCache();
    queryClient.setQueryData(["settings", "environment", "pending-changes", runtimeKey], true);
    resetApply();
    client?.setUserEnvPendingChanges(true, runtimeKey).catch(() => undefined);

    toast.info(t("settings.environment.restart_required"));
  }, [client, resetApply, queryClient, runtimeKey]);

  const { mutate: modifyAsync, isPending: isModifying, reset: resetModify, error: modifyError } = useMutation({
    mutationFn: async (nextEditor: EnvironmentEditorDraft) => {
      if (!client) {
        throw new Error(t("app.unknown_error"));
      }

      const keyError = validateKey(nextEditor.key);

      if (keyError) {
        throw new Error(keyError);
      }

      const key = nextEditor.key.trim();
      const existingItems = queryClient.getQueryData<{ items: EnvironmentVariableItem[] }>(
        environmentUserEnvQueryKey(runtimeKey),
      )?.items;

      if (nextEditor.mode === "add" && existingItems?.some((item) => item.key === key)) {
        throw new Error(t("settings.environment.validation_duplicate"));
      }

      return client.upsertUserEnv([{ key, value: nextEditor.value }]);

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Reconnect to the server / restart the app so the client initializes, then retry
  2. Wait for the client/connection to be ready before enabling the save action
  3. Check app logs for why client initialization failed

Example fix

// before
modifyAsync(draft); // client may be null
// after
if (!client) return;
modifyAsync(draft);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!client) {
  showReconnectToast();
  return;
}
modifyAsync(draft);

Type guard

const hasClient = (c: Client | null | undefined): c is Client => c != null;

Try / catch

try {
  modifyAsync(draft);
} catch (e) {
  if ((e as Error).message.includes("unknown_error")) promptReconnect();
  else throw e;
}

Prevention

When it happens

Trigger: Submitting the environment variable editor (upsert) before the client is available — e.g. during app startup, after a server disconnect, or on a runtime where client injection failed.

Common situations: User edits env vars while the backend/server connection is down; race between app boot and user interaction; remote workspace where the client never initialized.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/7fb9496ec4d91eca. Report an issue: GitHub.