Repository navigation
fix(active-memory): skip non-string entries in pluginConfig.agents du… - #68837
SimbaKingjoe wants to merge 1 commit into
Conversation
…ring normalization
Greptile SummaryThis PR adds a defensive type guard filter in Confidence Score: 5/5Safe to merge — minimal, focused fix with a matching regression test and no behavior change for valid configs. The change is a one-line-equivalent type guard that exactly mirrors the existing defensive pattern already used for allowedChatTypes in the same function. The test covers the described failure scenario end-to-end. No API, schema, or runtime logic is altered. No files require special attention. Reviews (1): Last reviewed commit: "fix(active-memory): skip non-string entr..." | Re-trigger Greptile |
|
Closing this as not reproducible on current Current What I checked:
Codex Review notes: reviewed against 938b53698ec1. |
fix(active-memory): skip non-string entries in pluginConfig.agents during normalization
Summary
normalizePluginConfigfunction previously called.map((agentId) => agentId.trim())directly onraw.agentswithout first filtering out non-string values. WhenpluginConfig.agentscontained non-string entries (e.g.,null,42, or other invalid types), the.trim()method would throw a runtime error (agentId.trim is not a function), causing the plugin registration to crash.filter((agentId): agentId is string => typeof agentId === "string")before the.map()and.filter(Boolean)chain. Non-string entries are now silently skipped during normalization, and only valid string agent IDs proceed through trimming and empty-string filtering.agentsarrays (all string entries) remains identical. The plugin's runtime functionality, hooks, and memory search logic are completely unaffected. No changes to public API or configuration schema.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
raw.agentswould always be an array of strings. When non-string values appeared, calling.trim()on them caused a runtimeTypeErrorbecause non-string primitives (andnull/undefined) lack a.trim()method.pluginConfig.agentscontained non-string entries. Existing tests only validated the happy path with clean string arrays.Regression Test Plan (if applicable)
extensions/active-memory/index.test.ts(new test case:"tolerates non-string entries in pluginConfig.agents without crashing register")pluginConfig.agentsset to["main", null, 42, "", " support "](mixed valid strings, null, number, and empty string). Registration should not throw, and valid agent IDs (including"support"after trimming) should still trigger the expected hooks.plugin.register()with malformed configuration isolates the regression without requiring full integration or E2E setup.User‑visible / Behavior Changes
None. This fix prevents a crash that would otherwise occur with malformed configuration. Users with correctly configured
agentsarrays will see no difference. Users with malformed config will now see the plugin register successfully (with non-string entries ignored) instead of crashing.Diagram (if applicable)