nrkno / sofie-mos-connection

Sofie MOS Connection: A Part of the Sofie TV Studio Automation System
https://github.com/nrkno/Sofie-TV-automation/
MIT License
22 stars 14 forks source link

Converting a MOS object with a circular structure #83

Closed PascalViauRC closed 9 months ago

PascalViauRC commented 9 months ago

I'm doing some tests with an iNews Mos Gateway. When there is no MOS object in the stories, everything works fine. When I add a MOS object to a story, I get this error while it converts XML to JSON :

TypeError: Converting circular structure to JSON\n --> starting at object with constructor 'Object'\n | property 'mos' -> object with constructor 'Object'\n --- property 'parent' closes the circle

The problem seems to be that the iNews MOS object starts with the same <mos> root tag than the iNews story itself :

<mos>
  ...
    <roStorySend>
    ...
      <mosExternalMetadata>
        <mosPayload>
        ...
          <nsml xmlns:nsml="http://www.avid.com">
          ...
            <aeset-atts>
              <attachment id="1">
                <AttachmentContent>
                  <mos>
                    <mosID>
                 VIZRT
                </mosID>
                     ...
                  </mos>
                </AttachmentContent>
              </attachment>
            </aeset-atts>
         </nsml>
      </mosPayload>
    </mosExternalMetadata>
  </roStorySend>
</mos>

When I replace the MOS object first tag (<mos>) by a modified tag (<_mos>), it fixes the problem :

<mos>
  ...
    <roStorySend>
    ...
      <mosExternalMetadata>
        <mosPayload>
        ...
          <nsml xmlns:nsml="http://www.avid.com">
          ...
            <aeset-atts>
              <attachment id="1">
                <AttachmentContent>
                  <_mos>
                    <mosID>
                 VIZRT
                </mosID>
                     ...
                  </_mos>
                </AttachmentContent>
              </attachment>
            </aeset-atts>
         </nsml>
      </mosPayload>
    </mosExternalMetadata>
  </roStorySend>
</mos>

If you want me to submit a pull request with the code I used to fix the problem, let me know !

nytamin commented 9 months ago

hmm, that's a strange bug indeed!

I did a little digging and it seems like there is a bug in the code that deals with reading the incoming message chunks. I think I've found the root cause and have implemented a fix in the PR #85.

@PascalViauRC would you be able to give that a spin (npm install @mos-connection/connector@3.0.5-nightly-fix-multiple-mos-tags-20231214-120351-59cacb2.0), to see if it helps?

PascalViauRC commented 9 months ago

@nytamin It fixes the problem, thanks !

nytamin commented 9 months ago

The fix for this is now published in version 3.0.6