Skip to content
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

Extending Asset with Contract or Clause causes Archive error #791

Open
martinhalford opened this issue Jul 27, 2023 · 2 comments
Open

Extending Asset with Contract or Clause causes Archive error #791

martinhalford opened this issue Jul 27, 2023 · 2 comments
Assignees
Labels
Type: Bug 🐛 Something isn't working

Comments

@martinhalford
Copy link
Member

Bug Report 🐛

The cicero archive command requires a valid package.json file which must contain either:

    "accordproject": {
      "template": "clause",
      "cicero": "^0.24.0",
      "runtime": "ergo"
    },

-- OR --

    "accordproject": {
      "template": "contract",
      "cicero": "^0.24.0",
      "runtime": "ergo"
    },

Note: Without this object in the package.json file, the cicero archive command throws the following expected error:

ERROR: /Users/martin/hello-world is not a valid cicero template. Make sure that package.json exists and that it has a cicero entry.

Assume you have the following grammar.tem.md file:

namespace [email protected]

@template
concept HelloWorld {
    o String name
}

Attempting to execute cicero archive as a Clause template with this grammar.tem.md will result in the error:

ERROR: Failed to find an asset that extends org.accordproject.contract.Clause. The model for the template must contain a single asset that extends org.accordproject.contract.Clause.

Attempting to execute cicero archive as a Contract template with this grammar.tem.md will result in the error:

ERROR: Failed to find an asset that extends org.accordproject.contract.Contract. The model for the template must contain a single asset that extends org.accordproject.contract.Contract.

Attempted Fix 1:

Attempt to fix the issue by adding extends Contract or extends Clause to concept, like so:

namespace [email protected]

@template
concept HelloWorld extends Contract {
    o String name
}

This results in the error:

ERROR: Could not find super type Contract File '/Users/martin/hello-world/model/model.cto': line 3 column 1, to line 6 column 2.

-- OR --

namespace [email protected]

@template
concept HelloWorld extends Clause {
    o String name
}

This results in the error:

ERROR: Could not find super type Clause File '/Users/martin/hello-world/model/model.cto': line 3 column 1, to line 6 column 2.

Attempted Fix 2:

Add contract import to model.cto like so:

namespace [email protected]

import [email protected] from https://models.accordproject.org/accordproject/[email protected]

@template
concept HelloWorld extends Contract {
    o String name
}

This results in the error:

ERROR: ConceptDeclaration (HelloWorld) cannot extend AssetDeclaration (Contract) File '/Users/martin/hello-world/model/model.cto': line 5 column 1, to line 8 column 2.

Context (Environment)

  • Cicero Version: 0.24.1-20230722135139
  • Concerto Version: 3.12.0

Summary

It seems that cicero archive requires an asset to extend either Contract or Clause but the concerto syntax no longer considers this as valid syntax.

Note: Also tried concerto compile --model ./hello-world/model/model.cto --target Rust and got same error.

@martinhalford martinhalford added the Type: Bug 🐛 Something isn't working label Jul 27, 2023
@dselman
Copy link
Contributor

dselman commented Jul 30, 2023

We should use:

import { templatemarkutil } from '@accordproject/markdown-template';
...
templatemarkutil.findTemplateConcept(introspector, 'clause', templateConceptFqn);

To find the template class.

@martinhalford
Copy link
Member Author

martinhalford commented Jul 31, 2023

@mttrbrts @dselman - Not surprisingly, error occurs for other cicero commands too.

% cicero --version                                                   
0.24.1-20230722135139
% cicero compile --template ./hello-world --target Rust --output ./
1:18:13 pm - ERROR: Failed to find an asset that extends org.accordproject.contract.Contract. The model for the template must contain a single asset that extends org.accordproject.contract.Contract.
Error: Failed to find an asset that extends org.accordproject.contract.Contract. The model for the template must contain a single asset that extends org.accordproject.contract.Contract.
    at findTemplateModel (/Users/martin/.nvm/versions/node/v19.9.0/lib/node_modules/@accordproject/cicero-cli/node_modules/@accordproject/markdown-template/lib/templatemarkutil.js:108:11)
    at templateMarkTyping (/Users/martin/.nvm/versions/node/v19.9.0/lib/node_modules/@accordproject/cicero-cli/node_modules/@accordproject/markdown-template/lib/templatemarkutil.js:162:15)
    at ParserManager.initParser (/Users/martin/.nvm/versions/node/v19.9.0/lib/node_modules/@accordproject/cicero-cli/node_modules/@accordproject/markdown-template/lib/parsermanager.js:186:27)
    at ParserManager.buildParser (/Users/martin/.nvm/versions/node/v19.9.0/lib/node_modules/@accordproject/cicero-cli/node_modules/@accordproject/markdown-template/lib/parsermanager.js:198:12)
    at TemplateLoader.fromDirectory (/Users/martin/.nvm/versions/node/v19.9.0/lib/node_modules/@accordproject/cicero-cli/node_modules/@accordproject/cicero-core/src/templateloader.js:192:36)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
1:18:13 pm - INFO: Completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants