Proskomma / proskomma-json-tools

Tools for working with Proskomma-derived JSON formats such as PERF and SOFRIA
MIT License
1 stars 2 forks source link

Alignment merge with extra verse issue #46

Open JEdward7777 opened 8 months ago

JEdward7777 commented 8 months ago

When using the split merge workflow, the merge fails if an extra verse was added to the stripped usfm. A test showing this error is here: 5ed03d472a2fbe1d3401908d1b17e09d263eda35

mvahowe commented 8 months ago

Finally getting to this. The error in the test has nothing to do with adding a verse - not adding a verse results in the same error.

The error is Error: 2 input(s) expected by usfmToPerfPipeline but 1 provided (usfm) and appears to be accurate. You're using a pipeline that expects 2 inputs but only giving it one, and that pipeline isn't the one that does splitting or merging.

The missing input is "selectors" which sounds like it wants the Proskomma document selectors.

This is why it would be better if we could do this using Epitelete, which is supposed to have a workflow corresponding to these pipelines.

mvahowe commented 8 months ago

The next problem is that you were passing

 {
  perf: {
    perf: {
      schema: [Object],
      metadata: [Object],
      sequences: [Object],
      main_sequence_id: 'ZmQwNWNmY2Ut'
    }
  }
}

into the pipeline. If I pull .perf out of that the pipeline works.

mvahowe commented 8 months ago

And now, having also made the pipeline handler errors a lot more informative, the pipeline works without a new verse but, with a new verse, I get

Cannot read properties of undefined (reading 'after--Testing--1--1')

which I think is the thing we were initially trying to debug, and which still looks trivial to fix. (Famous last words...)

mvahowe commented 8 months ago

Sure enough, the error is around

const markup = strippedAlignment[chapter][verses];

If there's no record for the verse, markup is undefined, and then the first lookup inside markup croaks.

mvahowe commented 8 months ago

And

const markup = strippedAlignment[chapter][verses] || {};

fixes it.

mvahowe commented 8 months ago

Finally,

t.same(output.perf, JSON.parse(perfContent))

will always fail because PERF uses UIDs for sequence names and they cannot be preserved when roundtripping via USFM.