Skip to content

fix(devtools-kit): guard state editor against undefined path traversal - #5

Open
arena-ai-coding-agent[bot] wants to merge 1 commit into
mainfrom
fix/issue-906-editor-crash-guard
Open

fix(devtools-kit): guard state editor against undefined path traversal#5
arena-ai-coding-agent[bot] wants to merge 1 commit into
mainfrom
fix/issue-906-editor-crash-guard

Conversation

@arena-ai-coding-agent

Copy link
Copy Markdown

Summary

Editing state from the component inspector (e.g. a Pinia store) throws an uncaught:

TypeError: this.refEditor.get(...) is undefined

Cause

In StateEditor.set(), the path used to locate the value may not exist on the target object. After traversing such a path, object becomes undefined, and the code then evaluates:

const item = this.refEditor.get(object)[field]

which reads a property off undefined and throws a TypeError. This is reproducible when the inspector passes a path that the component proxy does not have (e.g. a Pinia state path from the Components tab).

Fix

Stop the edit gracefully when the path does not resolve, instead of throwing. An early if (object == null) return is added both inside the traversal loop and before the final field access. Legitimate edits are unaffected.

Tests

Added a regression test asserting that editing via a non-existing nested path does not throw. The full suite passes (86 tests) along with type-check, lint, and build.

Closes vuejs#906

When editing state from the component inspector (e.g. a Pinia store), the
path used to locate the value may not exist on the target object. After
traversing such a path, `StateEditor.set` did `this.refEditor.get(object)[field]`
where `object` was `undefined`, throwing:
`TypeError: this.refEditor.get(...) is undefined`.

Stop the edit silently when the path does not resolve instead of throwing.

Adds a regression test asserting a non-existing nested path does not throw.

Closes vuejs#906
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: this.refEditor.get(...) is undefined. Editing Pinia state on component causes error.

1 participant