fix(terminal): guard formatDocsLink against undefined path#66754
fix(terminal): guard formatDocsLink against undefined path#66754MukundaKatta wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryAdds a null/undefined guard to Confidence Score: 5/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/terminal/links.test.ts
Line: 10
Comment:
**Unnecessary double-cast in tests**
Since the function signature was just updated to `path: string | undefined | null`, passing `undefined` or `null` is now fully typed — the `as unknown as string` double-cast is no longer needed and slightly obscures intent. The same applies to lines 16 and 21.
```suggestion
formatDocsLink(undefined, "label", { force: false }),
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(terminal): guard formatDocsLink agai..." | Re-trigger Greptile |
| // when a ChannelMeta entry reached this helper without a `docsPath`. | ||
| it("does not throw when path is undefined", () => { | ||
| expect(() => | ||
| formatDocsLink(undefined as unknown as string, "label", { force: false }), |
There was a problem hiding this comment.
Unnecessary double-cast in tests
Since the function signature was just updated to path: string | undefined | null, passing undefined or null is now fully typed — the as unknown as string double-cast is no longer needed and slightly obscures intent. The same applies to lines 16 and 21.
| formatDocsLink(undefined as unknown as string, "label", { force: false }), | |
| formatDocsLink(undefined, "label", { force: false }), |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/terminal/links.test.ts
Line: 10
Comment:
**Unnecessary double-cast in tests**
Since the function signature was just updated to `path: string | undefined | null`, passing `undefined` or `null` is now fully typed — the `as unknown as string` double-cast is no longer needed and slightly obscures intent. The same applies to lines 16 and 21.
```suggestion
formatDocsLink(undefined, "label", { force: false }),
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Addressed in ce7f6c0 — dropped the as unknown as string casts on lines 10, 16, and 21 now that the signature accepts undefined | null directly. Tests still pass (6/6).
…tests Greptile review nit on openclaw#66754: the `formatDocsLink` signature already accepts `string | undefined | null`, so the double-cast in the regression tests is no longer needed and slightly obscures intent.
|
Linking duplicate user reports of the same
All four hit the same |
|
Confirmed this patch fixed my setup flow as well (arcee+telegram). |
Running `openclaw configure` crashed on the Channels section with:
TypeError: Cannot read properties of undefined (reading 'trim')
at formatDocsLink (src/terminal/links.ts)
at formatChannelSelectionLine (src/channels/registry.ts)
This happens when a `ChannelMeta` entry reaches `formatDocsLink` with
an `undefined` (or empty) `docsPath`. The existing code unconditionally
called `path.trim()`.
Accept `path: string | undefined | null` and fall back to the docs
root when no path is provided, so the configure wizard can still
render a usable (if generic) docs link instead of crashing.
Add `src/terminal/links.test.ts` with regression coverage for the
undefined/null paths plus the existing shape contracts.
Fixes openclaw#66718
AI-assisted: drafted with Claude. Tested with `pnpm vitest run
src/terminal/links.test.ts` (6/6 pass).
ce7f6c0 to
a702c35
Compare
Summary
openclaw configurecrashed on the Channels section withTypeError: Cannot read properties of undefined (reading 'trim')when aChannelMetaentry reachedformatDocsLinkwith anundefined/empty `docsPath`.Why
This is a pure defensive fix at the helper: a missing `docsPath` is a latent data bug elsewhere, but the user-facing effect was a wizard crash. Stopping the crash restores the wizard; the underlying data gap is a separate issue.
Test plan
AI-assisted disclosure