Skip to content

Conversation

@ubik2
Copy link
Contributor

@ubik2 ubik2 commented Sep 19, 2025

When following a pointer, adjust targetDoc to point to the root of the current doc, since our pointers may point outside of the portion where we are.


Summary by cubic

Fixes pointer traversal to start from the root of the target document so paths outside the current subdocument resolve correctly. Addresses CT-922 (traverse mismatched paths across docs).

  • Bug Fixes
    • Reload target doc via manager and pass its value root to getAtPath.
    • Track schema dependency when crossing docs; load sources/recipes unless retracted.
    • Return notFound when target is missing or retracted.
    • Added unit test covering legacy cell links and alias resolution.

…e current doc, since our pointers may point outside of the portion where we are.
@linear
Copy link

linear bot commented Sep 19, 2025

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/runner/src/traverse.ts">

<violation number="1" location="packages/runner/src/traverse.ts:524">
Potential runtime error: valueEntry.value may be null or non-object; guard with isObject before accessing [&quot;value&quot;].</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

// that's what our schema is relative to, so we'll grab the value part.
const targetDoc = {
address: { ...target, path: ["value"] },
value: (valueEntry.value as Immutable<JSONObject>)["value"],
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential runtime error: valueEntry.value may be null or non-object; guard with isObject before accessing ["value"].

Prompt for AI agents
Address the following comment on packages/runner/src/traverse.ts at line 524:

<comment>Potential runtime error: valueEntry.value may be null or non-object; guard with isObject before accessing [&quot;value&quot;].</comment>

<file context>
@@ -492,43 +488,47 @@ function followPointer&lt;S extends BaseMemoryAddress&gt;(
+  // that&#39;s what our schema is relative to, so we&#39;ll grab the value part.
+  const targetDoc = {
+    address: { ...target, path: [&quot;value&quot;] },
+    value: (valueEntry.value as Immutable&lt;JSONObject&gt;)[&quot;value&quot;],
+  };
 
</file context>
Suggested change
value: (valueEntry.value as Immutable<JSONObject>)["value"],
value: isObject(valueEntry.value) ? (valueEntry.value as Immutable<JSONObject>)["value"] : undefined,
Fix with Cubic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps an argument for a better return type for manager.load, where we indicate that if the valueEntry returned has a defined value, that it will be an object with a value property.
However, I'm not going to address that in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion—refining manager.load’s return type to encode the value shape (e.g., via a discriminated union or type guard) would help avoid unsafe property access. Understood that it won’t be changed in this PR; I’ll keep this in mind for future reviews.

@ubik2 ubik2 requested a review from seefeldb September 19, 2025 21:05
@ubik2 ubik2 self-assigned this Sep 19, 2025
@ubik2 ubik2 merged commit ff9dca7 into main Sep 19, 2025
7 checks passed
@ubik2 ubik2 deleted the robin/ct-922-traverse-mismatched-paths branch September 19, 2025 21:35
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.

3 participants