Failed to find AccordClause for a template
The template below doesn't parse using Cicero 0.21.4
signature-block-title-name-date.zip
It fails with the error message:
Failed to find an asset that extends org.accordproject.cicero.contract.AccordClause. The model for the template must contain a single asset that extends org.accordproject.cicero.contract.AccordClause.
Error: Failed to find an asset that extends org.accordproject.cicero.contract.AccordClause. The model for the template must contain a single asset that extends org.accordproject.cicero.contract.AccordClause.
at findTemplateModel (/Users/dselman/.nvm/versions/node/v12.16.1/lib/node_modules/@accordproject/cicero-cli/node_modules/@accordproject/markdown-template/lib/templatemarkutil.js:95:15)
at templateMarkTyping (/Users/dselman/.nvm/versions/node/v12.16.1/lib/node_modules/@accordproject/cicero-cli/node_modules/@accordproject/markdown-template/lib/templatemarkutil.js:149:19)
To Reproduce Steps to reproduce the behavior:
- Unzip
- Run
cicero parse
Expected behavior
The template should parse (I think!) because it contains a type DetailedSignatureBlock that extends an abstract type SignatureBlock that extends AccordClause.
We should leave this issue open, but this version of the same template works. Changing the namespace in ./model/model.cto from namespace org.accordproject.signature to namespace org.accordproject.signature.detailed avoiding a collision with the namespace in https://models.accordproject.org/signature/signature.cto
signature-block-title-name-date.zip
This works with Cicero 0.21
bash-3.2$ cicero --version
0.21.4
bash-3.2$ cicero parse
6:22:15 PM - info: Using current directory as template folder
6:22:15 PM - info: Loading a default text/sample.md file.
[xmldom warning] attribute "at" missed value!! "at" instead2!!
@#[line:1,col:1]
[xmldom warning] attribute "signature" missed value!! "signature" instead!!
@#[line:1,col:1]
[xmldom warning] attribute "at" missed value!! "at" instead2!!
@#[line:1,col:1]
[xmldom warning] attribute "signature" missed value!! "signature" instead!!
@#[line:1,col:1]
[xmldom warning] attribute "at" missed value!! "at" instead2!!
@#[line:1,col:1]
[xmldom warning] attribute "signature" missed value!! "signature" instead!!
@#[line:1,col:1]
[xmldom warning] attribute "at" missed value!! "at" instead2!!
@#[line:1,col:1]
[xmldom warning] attribute "signature" missed value!! "signature" instead!!
@#[line:1,col:1]
6:22:16 PM - info:
{
"$class": "org.accordproject.signature.detailed.DetailedSignatureBlock",
"title": "<supplied at signature>",
"signature": "<supplied at signature>",
"fullName": "<supplied at signature>",
"dateSigned": "<supplied at signature>",
"signatory": "resource:org.accordproject.cicero.contract.AccordParty#[email protected]",
"clauseId": "9943494b-e5e1-4624-ac23-c8881f70e1a0"
}
bash-3.2$ cicero parse
cicero parse
6:22:19 PM - info: Using current directory as template folder
6:22:19 PM - info: Loading a default text/sample.md file.
[xmldom warning] attribute "at" missed value!! "at" instead2!!
@#[line:1,col:1]
[xmldom warning] attribute "signature" missed value!! "signature" instead!!
@#[line:1,col:1]
[xmldom warning] attribute "at" missed value!! "at" instead2!!
@#[line:1,col:1]
[xmldom warning] attribute "signature" missed value!! "signature" instead!!
@#[line:1,col:1]
[xmldom warning] attribute "at" missed value!! "at" instead2!!
@#[line:1,col:1]
[xmldom warning] attribute "signature" missed value!! "signature" instead!!
@#[line:1,col:1]
[xmldom warning] attribute "at" missed value!! "at" instead2!!
@#[line:1,col:1]
[xmldom warning] attribute "signature" missed value!! "signature" instead!!
@#[line:1,col:1]
6:22:20 PM - info:
{
"$class": "org.accordproject.signature.detailed.DetailedSignatureBlock",
"title": "<supplied at signature>",
"signature": "<supplied at signature>",
"fullName": "<supplied at signature>",
"dateSigned": "<supplied at signature>",
"signatory": "resource:org.accordproject.cicero.contract.AccordParty#[email protected]",
"clauseId": "0a594546-4f20-4a82-b4cc-9da8049dc7f4"
}
Note that you would have gotten an error with the same template in 0.20
bash-3.2$ cicero --version
0.20.10
bash-3.2$ cicero parse
6:25:56 PM - info: Using current directory as template folder
6:25:56 PM - info: Loading a default text/sample.md file.
6:25:57 PM - error: Type error (at file text/grammar.tem.md line 3 col 13). The field `signature' does not exist in type `~org.accordproject.signature.SignatureBlock'
Signature: {{signature}}
^^^^^^^^^
A bit of diagnosis for future consideration:
- Finding the "right" class deriving from
AccordClauseorAccordContractin the context of a hierarchy isn't particularly easy -- making that magic rather than specified by the user is a bit of a trade off. - We should provide a better error message in Concerto when there are namespace collision (it's currently not an error in all scenarios either)
- We should ensure that the behaviour when updating external models and when finding those same model locally is the same. (it currently isn't in the template provided in the issue)
- The reason
0.20and0.21differ is that it now skips abstract classes. Corresponding code in0.20https://github.com/accordproject/cicero/blob/2429bb97d9ac0e6ffb6ec7306271baaeae6025d8/packages/cicero-core/src/template.js#L415 Corresponding code in0.21https://github.com/accordproject/markdown-transform/blob/9b5d3334e3d21fa78bbd0e9dc1b018bb91afb1dc/packages/markdown-template/lib/templatemarkutil.js#L89
[0.20 picks the abstract super class rather than the one in the template]