feat(FN-4749): complete Step 1 — normalize missing apiKey message

Fusion-Task-Id: FN-4749
Fusion-Task-Lineage: 4d1f47b6-1df7-4e1b-8c45-0c2d1d4957c3
This commit is contained in:
Fusion (runfusion.ai)
2026-05-16 10:42:41 -07:00
committed by gsxdsm
parent 78402db294
commit de71cafa13
2 changed files with 10 additions and 3 deletions

View File

@@ -3,6 +3,8 @@ import type { AuthMaterialSnapshot, NodeConfig, ProviderAuthEntry } from "@fusio
import { ApiError } from "../api-error.js";
import { getAuthFileCandidates, type StoredAuthProvider } from "../auth-paths.js";
export const MISSING_REMOTE_NODE_API_KEY_MESSAGE = "Remote node requires an apiKey for authenticated sync";
export async function readStoredAuthProvidersFromDisk(): Promise<Record<string, StoredAuthProvider>> {
const merged: Record<string, StoredAuthProvider> = {};
for (const authJsonPath of getAuthFileCandidates()) {
@@ -66,7 +68,7 @@ export async function fetchFromRemoteNode(
// Validate node has apiKey (secure sync requires node authentication)
if (!node.apiKey) {
throw new ApiError(400, "Remote node requires an apiKey for authenticated sync");
throw new ApiError(400, MISSING_REMOTE_NODE_API_KEY_MESSAGE);
}
const method = options?.method ?? "GET";

View File

@@ -2,7 +2,12 @@ import type { ProjectSettings } from "@fusion/core";
import { basename } from "node:path";
import { ApiError, badRequest, notFound } from "../api-error.js";
import { getFusionAuthPath } from "../auth-paths.js";
import { fetchFromRemoteNode, readStoredAuthProvidersFromDisk, toProviderAuthEntries } from "./register-settings-sync-helpers.js";
import {
fetchFromRemoteNode,
MISSING_REMOTE_NODE_API_KEY_MESSAGE,
readStoredAuthProvidersFromDisk,
toProviderAuthEntries,
} from "./register-settings-sync-helpers.js";
import type { ApiRouteRegistrar } from "./types.js";
function computeSettingsDiff(
@@ -347,7 +352,7 @@ export const registerSettingsSyncRoutes: ApiRouteRegistrar = (ctx) => {
if (!node.apiKey) {
await central.close();
throw badRequest("Remote node requires an apiKey for auth sync");
throw badRequest(MISSING_REMOTE_NODE_API_KEY_MESSAGE);
}
const direction = req.body?.direction ?? "push";