Skip to content

fix(ngxs): missing null check before accessing meta.version property#1539

Merged
splincode merged 2 commits intoAngular-RU:mainfrom
prjanitor:prjanitor/ec0ee7c7a7b598cd4cd68a1bc35407719d1eaa6a
Apr 2, 2026
Merged

fix(ngxs): missing null check before accessing meta.version property#1539
splincode merged 2 commits intoAngular-RU:mainfrom
prjanitor:prjanitor/ec0ee7c7a7b598cd4cd68a1bc35407719d1eaa6a

Conversation

@prjanitor
Copy link
Copy Markdown
Contributor

Bug Fix: Missing null check in versionIsInvalid

Problem

The versionIsInvalid function in deserializeByStorageMeta accesses meta.version without checking if meta is null or undefined. If storage returns null/undefined data, this causes a runtime crash with 'Cannot read property 'version' of null/undefined'.

Solution

Added a defensive null check at the beginning of versionIsInvalid function that returns true (invalid) when meta is null or undefined, preventing the runtime crash.

Changes

  • Modified versionIsInvalid function in libs/ngxs/storage/utils/deserialize-by-storage-meta.ts
  • Added if (!meta) { return true; } check before accessing meta.version

Testing

This fix ensures that when storage returns null/undefined data, the function gracefully handles it by returning true (version is invalid) instead of crashing.


This PR was generated by PRJanitor — an automated tool that finds and fixes small bugs in open-source projects.

We respect your contribution guidelines — if your project doesn't accept bot PRs, we won't send more. You can also add a .github/prjanitor.yml file with enabled: false to opt out explicitly.

@splincode splincode changed the title Fix missing null check before accessing meta.version property fix(ngxs): missing null check before accessing meta.version property Apr 2, 2026
@splincode splincode merged commit 2970404 into Angular-RU:main Apr 2, 2026
3 checks passed
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.

2 participants