-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Support non-spec MOS data better #88
Conversation
Now, mosTime will throw on all invalid input formats
Introducing createRequired and createOptional, used to better handle missing data (filling in fallback data in non-strict mode)
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #88 +/- ##
==========================================
- Coverage 78.17% 77.21% -0.96%
==========================================
Files 63 65 +2
Lines 3422 3634 +212
Branches 778 848 +70
==========================================
+ Hits 2675 2806 +131
- Misses 668 744 +76
- Partials 79 84 +5 ☔ View full report in Codecov by Sentry. |
If a reply is unparseable in strict mode, a MosReplyError will now be thrown, which can expose a non-strict message (if possible)
Hello! Thank you for contributing to the Sofie Project! If you haven’t already, please give our contribution guidelines a read. We will reach out to you to schedule an initial discussion regarding this (more details to follow). |
We don't think we need a discussion on this. More leeway for not-entirely MOS-compliant systems seems a good idea. |
About the Contributor
This PR is posted on behalf of SuperFly.tv
Type of Contribution
This is a:
Code improvement. An attempt at making mos-connection better at handling off-spec messages.
This PR is another try at fixing the issues behind #84
Current Behavior
If we receive a message that is not according to the specification, like for example if calling
await mosDevice.requestMachineInfo()
and receiving the reply<listMachInfo>
:<time>
is missing: Returns an object wheretime
is populated with a MosTime with valueDate.now()
<time>
is empty: Throws withError: MosTime: Invalid input: \"[object Object]\"
<time>
is badly formatted: Throws withError: MosTime: Invalid timestamp: \"BAD DATA\"
<opTime>
is missing: Returns an object wheretime
is populated with a MosTime with valueDate.now()
<opTime>
is empty: Throws withError: MosTime: Invalid input: \"[object Object]\"
<opTime>
is badly formatted: Throws withError: MosTime: Invalid timestamp: \"BAD DATA\"
Why this is bad:
(Note: According to the MOS protocol,
<time>
is required and<opTime>
is optional.)<time>
is real or fictional (like in 1 or 4).New Behavior
If calling
await mosDevice.requestMachineInfo()
:If in strict mode:
<time>
is missing: Throws withError: MosTime: Invalid input: "undefined"
<time>
is empty: Throws withError: MosTime: Invalid input: "undefined"
<time>
is badly formatted: Throws withError: MosTime: Invalid timestamp: "BAD DATA"
<opTime>
is missing: Returns an object whereopTime
isundefined
.<opTime>
is empty: Returns an object whereopTime
isundefined
.<opTime>
is badly formatted: Throws withError: MosTime: Invalid timestamp: "BAD DATA"
If in non-strict mode:
<time>
is missing: Returns an object where thetime
field is populated with a MosTime with value0
<time>
is empty: Returns an object where thetime
field is populated with a MosTime with value0
<time>
is badly formatted: Throws withError: MosTime: Invalid timestamp: "BAD DATA"
<opTime>
is missing: Returns an object whereopTime
isundefined
<opTime>
is empty: Returns an object whereopTime
isundefined
<opTime>
is badly formatted: Throws withError: MosTime: Invalid timestamp: "BAD DATA"
Testing Instructions
Basic regression testing should be enough.
Other Information
Status