Skip to content

fix(@hertzg/hikvision-api): read an empty optional element as absent - #307

Merged
hertzg merged 1 commit into
mainfrom
hertzg/hikvision-api-empty-regionid
Oct 25, 2026
Merged

hertzg merged 1 commit into
mainfrom
hertzg/hikvision-api-empty-regionid

Conversation

@hertzg

@hertzg hertzg commented Oct 25, 2026

Copy link
Copy Markdown
Owner

An AcuSense camera through an NVR posts fielddetection alerts with an empty <regionID></regionID>. optional(int()) threw and the whole alert stream errored for every channel.

  • decodeFields treats an optional element with no text, children or attributes as absent; a required one still throws.
  • Alert gains pictureUrl (<bkgUrl>) and pictureTransport (<detectionPictureTransType>).
  • Regression test with the sanitized post.

…so one bad regionID cannot end the alert stream

An AcuSense camera relayed by an NVR posts fielddetection alerts whose
DetectionRegionEntry has an empty <regionID></regionID>. optional(int())
threw, the error surfaced from the ReadableStream, and every channel's
alerts stopped until the consumer reconnected. decodeFields now treats an
optional element with no text, children or attributes as missing, so the
region reads without an id. Alerts also expose the snapshot: pictureUrl
from <bkgUrl> and pictureTransport from <detectionPictureTransType>.
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview: https://hertzg.github.io/jsr-monorepo/pr/307/

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results

No significant changes detected. 31 benchmark(s) within their noise floor.

@hertzg
hertzg merged commit 094a039 into main Oct 25, 2026
6 checks passed
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.82%. Comparing base (a40f5ba) to head (96681b5).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rtzg/hikvision-api/isapi/document/decode-fields.ts 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #307   +/-   ##
=======================================
  Coverage   97.81%   97.82%           
=======================================
  Files         424      424           
  Lines       14712    14731   +19     
  Branches     1560     1566    +6     
=======================================
+ Hits        14390    14410   +20     
  Misses        186      186           
+ Partials      136      135    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants