mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-15 23:24:03 -06:00
fix(plugins): ignore malformed build version metadata (#117639)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { validatePluginConfig } from "./loader-shared.js";
|
||||
import type { PluginCandidate } from "./discovery.js";
|
||||
import { createManifestPluginRecord, validatePluginConfig } from "./loader-shared.js";
|
||||
import type { PluginManifestRecord } from "./manifest-registry.js";
|
||||
|
||||
const emptyObjectSchema = {
|
||||
type: "object",
|
||||
@@ -11,6 +13,50 @@ function withSchemaKeyword(key: "if" | "then" | "else", value: unknown) {
|
||||
return { [key]: value };
|
||||
}
|
||||
|
||||
const manifestRecord = {
|
||||
id: "example",
|
||||
channels: [],
|
||||
providers: [],
|
||||
cliBackends: [],
|
||||
skills: [],
|
||||
hooks: [],
|
||||
origin: "global",
|
||||
rootDir: "/plugins/example",
|
||||
source: "/plugins/example/index.js",
|
||||
manifestPath: "/plugins/example/openclaw.plugin.json",
|
||||
} satisfies PluginManifestRecord;
|
||||
|
||||
function createRecordWithBuildVersion(openclawVersion: unknown) {
|
||||
const candidate = {
|
||||
idHint: "example",
|
||||
source: manifestRecord.source,
|
||||
rootDir: manifestRecord.rootDir,
|
||||
origin: manifestRecord.origin,
|
||||
packageManifest: {
|
||||
build: { openclawVersion },
|
||||
} as unknown as NonNullable<PluginCandidate["packageManifest"]>,
|
||||
} satisfies PluginCandidate;
|
||||
|
||||
return createManifestPluginRecord({
|
||||
candidate,
|
||||
manifestRecord,
|
||||
enabled: true,
|
||||
activationState: {
|
||||
enabled: true,
|
||||
activated: true,
|
||||
explicitlyEnabled: true,
|
||||
source: "explicit",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
describe("createManifestPluginRecord", () => {
|
||||
it("ignores malformed package build version metadata", () => {
|
||||
expect(createRecordWithBuildVersion(" 2026.7.2 ").builtWithOpenClawVersion).toBe("2026.7.2");
|
||||
expect(createRecordWithBuildVersion(42).builtWithOpenClawVersion).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("validatePluginConfig empty schema classification", () => {
|
||||
it("validates pattern properties instead of requiring empty config", () => {
|
||||
const schema = {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { err as resultError, ok, type Result } from "@openclaw/normalization-core/result";
|
||||
import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce";
|
||||
import {
|
||||
normalizeLowercaseStringOrEmpty,
|
||||
normalizeOptionalString,
|
||||
} from "@openclaw/normalization-core/string-coerce";
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import { activateContextEngineRegistrations } from "../context-engine/registry.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
@@ -285,7 +288,9 @@ export function createManifestPluginRecord(params: {
|
||||
description: manifestRecord.description,
|
||||
packageVersion: manifestRecord.packageVersion,
|
||||
version: manifestRecord.version,
|
||||
builtWithOpenClawVersion: candidate.packageManifest?.build?.openclawVersion?.trim(),
|
||||
builtWithOpenClawVersion: normalizeOptionalString(
|
||||
candidate.packageManifest?.build?.openclawVersion,
|
||||
),
|
||||
packageName: manifestRecord.packageName,
|
||||
format: manifestRecord.format,
|
||||
bundleFormat: manifestRecord.bundleFormat,
|
||||
|
||||
Reference in New Issue
Block a user