Skip to content

fix: return undefined from deepValue when path is missing - #12776

Merged
alumni merged 2 commits into
masterfrom
fix/12774-deep-value-missing-path
Aug 26, 2026
Merged

alumni merged 2 commits into
masterfrom
fix/12774-deep-value-missing-path

Conversation

@michaelbromley

@michaelbromley michaelbromley commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #12774

Description

OrmUtils.deepValue() walked a dotted property path segment by segment without checking that the previous segment resolved to anything, so a path that runs off the end of the object threw TypeError: Cannot read properties of undefined.

SelectQueryBuilder calls it in seven places to narrow select, order and relations down to the part that applies to a single relation, and all seven treat a missing path as "nothing specified for this relation". The call that surfaced the throw in an ordinary query is the one in the query-strategy branch of executeEntitiesAndRawResults(), which runs for every eager relation of the queried entity whenever find options are set. For a relation declared inside an embedded, relation.propertyPath is something like meta.owner; find options of { image: true } have no meta key, so the loop read owner of undefined.

deepValue() now returns undefined as soon as a segment resolves to null or undefined, which is what every call site already expects.

Tests

  • test/functional/relations/load-strategy/embedded-eager-relation covers the reported case: an entity with an eager relation inside an embedded, queried with relationLoadStrategy: 'query' and find options that name a different relation, plus the same case with select instead of relations. Both throw on master and pass with the fix. It sits next to the existing load-strategy/query tests and mirrors their disabledDrivers: ["spanner"].
  • Unit tests for OrmUtils.deepValue() in test/unit/util/orm-utils.test.ts covering a resolvable path and two unresolvable ones.

Full suite passes locally against better-sqlite3 (the one failure is the Redis cache integration test, which needs a container runtime).

@pkg-pr-new

pkg-pr-new Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
  • typeorm-sql-js-example

    npm i https://pkg.pr.new/typeorm@12776
    

commit: bf70082

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Issue test under test/github-issues ⊘ Outdated 📘 Rule violation ⚙ Maintainability
Description
The regression test for #12774 was added under test/github-issues/12774, but this issue-fix should
live in the functional test suite per the checklist. Keeping it as a per-issue test increases
long-term maintenance cost and reduces coverage consistency.
Code

test/github-issues/12774/issue-12774.test.ts[13]

+describe("github issues > #12774 deepValue() throws when find options omit an embedded that holds an eager relation", () => {
Evidence
PR Compliance ID 3 requires issue-fix tests to be added/updated in test/functional rather than
only under test/github-issues. This PR adds the #12774 regression as
test/github-issues/12774/issue-12774.test.ts, which matches the failure criteria for that rule.

Rule 3: Prefer functional tests over per-issue tests
test/github-issues/12774/issue-12774.test.ts[13-13]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The fix for #12774 adds a new regression test under `test/github-issues/12774`, but compliance requires issue fixes to be covered by the functional test suite (`test/functional`) rather than per-issue tests.
## Issue Context
Per-issue tests under `test/github-issues` tend to accumulate and are harder to maintain and discover than functional suite coverage.
## Fix Focus Areas
- test/github-issues/12774/issue-12774.test.ts[1-70]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


  • Author self-review: I have reviewed the code review findings, and addressed the relevant ones.

Grey Divider

Tip of the day
💡 Did you know, you can start a comment with 'qodo' or '@qodo' to chat about any finding

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@sonarqubecloud

Copy link
Copy Markdown

@Cprakhar
Cprakhar requested review from alumni and gioboa August 22, 2026 12:23
@alumni
alumni merged commit 5105371 into master Aug 26, 2026
49 of 50 checks passed
@alumni
alumni deleted the fix/12774-deep-value-missing-path branch August 26, 2026 07:01
@github-actions github-actions Bot added this to the 2.0.next milestone Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

deepValue() throws when find options omit an embedded that holds an eager relation

4 participants