gethomepage/homepage · error · Error

type must be a non-empty string

Error message

type must be a non-empty string

What it means

Thrown by addInfoWidget when the `type` argument is missing or not a non-empty string. Every entry in Homepage's widgets.yaml is keyed by widget type (e.g. resources, search, weather), so type is mandatory.

Source

Thrown at src/utils/mcp/homepage-mcp.js:233

    return {
      isError: true,
      ...textContent(`Service '${serviceName}' already exists in group '${groupName}'.`),
    };
  }

  group[groupName].push({ [serviceName]: serviceConfig });
  const content = dumpYamlConfig("services.yaml", services);
  return textContent(
    JSON.stringify({ written: "services.yaml", added: { group: groupName, service: serviceName }, content }, null, 2),
  );
}

function addInfoWidget(args) {
  const disabled = ensureWriteEnabled();
  if (disabled) return disabled;

  if (typeof args.type !== "string" || !args.type.trim()) {
    throw new Error("type must be a non-empty string");
  }

  const validation = validateYaml("widgets.yaml", readConfig("widgets.yaml"));
  if (!validation.valid) {
    return {
      isError: true,
      ...textContent(JSON.stringify(validation, null, 2)),
    };
  }

  const widgets = parseYamlConfig("widgets.yaml");
  if (!Array.isArray(widgets)) {
    throw new Error("widgets.yaml must contain a top-level array");
  }

  const type = args.type.trim();
  const options = args.options ?? {};
  assertPlainObject(options, "options");

View on GitHub (pinned to b6dca1ae03)

Solutions

  1. Provide type as a non-empty string matching a supported Homepage info widget (e.g. "resources", "search", "weather", "datetime").
  2. Consult the widgets.yaml docs (https://gethomepage.dev/configs/info-widgets/) for valid type names.
  3. Verify the tool-call arguments object actually contains the `type` key.
  4. Avoid trailing whitespace and quotes.

Example fix

// before
{ "options": { "latitude": 40.7 } }

// after
{ "type": "weather", "options": { "latitude": 40.7, "longitude": -74.0 } }
Defensive patterns

Strategy: validation

Validate before calling

function isNonEmptyString(v) {
  return typeof v === 'string' && v.trim().length > 0;
}
if (!isNonEmptyString(args.type)) {
  return { isError: true, message: 'type is required' };
}

Type guard

function isNonEmptyString(v) {
  return typeof v === 'string' && v.trim().length > 0;
}

Prevention

When it happens

Trigger: add_info_widget tool called with args.type undefined/null/non-string/empty/whitespace. Guard: `typeof args.type !== "string" || !args.type.trim()`.

Common situations: Client omits type expecting it to default; sends the widget options under type; uses a numeric code; whitespace-only value from templating.

Related errors


AI-assisted analysis of gethomepage/homepage@b6dca1ae03 (2026-08-13). Data as JSON: /api/errors/a5a20ce30fd5b983. Report an issue: GitHub.