Summary
org.accordproject.cicero.runtime.Obligation declares a mandatory relationship back to the governing contract:
abstract event Obligation {
--> Contract contract
--> Participant promisor optional
--> Participant promisee optional
o DateTime deadline optional
}
Any event emitted by a stateful template's logic that extends Obligation (e.g. PaymentObligationEvent) inherits this required contract field. When TemplateArchiveProcessor.trigger() builds the emitted event(s) and calls Serializer.fromJSON() on them, it does not populate contract, so validation fails with:
ValidationException: The instance "<namespace>.<EventType>#<uuid>" is missing the required field "contract".
It reproduces on every stateful template whose logic emits an event extending Obligation, since trigger() never sets the back-reference before serializing the event. We need to extend obligation for all the events as per the discussion here:
accordproject/template-archive#937 (review)
accordproject/template-archive#937 (comment)
Reproduction
- Use any stateful template whose contract logic emits an event that extends
org.accordproject.cicero.runtime.Obligation (e.g. a PaymentObligationEvent).
- Call
TemplateArchiveProcessor.trigger() against that template with a valid request/state.
- Observe:
ValidationException: The instance "<namespace>.<EventType>#<uuid>" is missing the required field "contract". at ResourceValidator.reportMissingRequiredProperty (.../concerto-core/dist/serializer/resourcevalidator.js:528:15) at ResourceValidator.visitClassDeclaration (.../concerto-core/dist/serializer/resourcevalidator.js:255:39) at ResourceValidator.visit (.../concerto-core/dist/serializer/resourcevalidator.js:69:25) at EventDeclaration.accept (.../concerto-core/dist/introspect/decorated.js:64:24) at ValidatedResource.validate (.../concerto-core/dist/model/validatedresource.js:114:26) at Serializer.fromJSON (.../concerto-core/dist/serializer.js:171:22) at .../template-engine/lib/TemplateArchiveProcessor.js:286:60 at Array.forEach (<anonymous>) at TemplateArchiveProcessor.trigger (.../template-engine/lib/TemplateArchiveProcessor.js:286:36)
@dselman @mttrbrts @DianaLease
Summary
org.accordproject.cicero.runtime.Obligationdeclares a mandatory relationship back to the governing contract:abstract event Obligation {
--> Contract contract
--> Participant promisor optional
--> Participant promisee optional
o DateTime deadline optional
}
Any event emitted by a stateful template's logic that extends
Obligation(e.g.PaymentObligationEvent) inherits this requiredcontractfield. WhenTemplateArchiveProcessor.trigger()builds the emitted event(s) and callsSerializer.fromJSON()on them, it does not populatecontract, so validation fails with:
ValidationException: The instance "<namespace>.<EventType>#<uuid>" is missing the required field "contract". It reproduces on every stateful template whose logic emits an event extending
Obligation, sincetrigger()never sets the back-reference before serializing the event. We need to extend obligation for all the events as per the discussion here:accordproject/template-archive#937 (review)
accordproject/template-archive#937 (comment)
Reproduction
org.accordproject.cicero.runtime.Obligation(e.g. aPaymentObligationEvent).TemplateArchiveProcessor.trigger()against that template with a valid request/state.
ValidationException: The instance "<namespace>.<EventType>#<uuid>" is missing the required field "contract". at ResourceValidator.reportMissingRequiredProperty (.../concerto-core/dist/serializer/resourcevalidator.js:528:15) at ResourceValidator.visitClassDeclaration (.../concerto-core/dist/serializer/resourcevalidator.js:255:39) at ResourceValidator.visit (.../concerto-core/dist/serializer/resourcevalidator.js:69:25) at EventDeclaration.accept (.../concerto-core/dist/introspect/decorated.js:64:24) at ValidatedResource.validate (.../concerto-core/dist/model/validatedresource.js:114:26) at Serializer.fromJSON (.../concerto-core/dist/serializer.js:171:22) at .../template-engine/lib/TemplateArchiveProcessor.js:286:60 at Array.forEach (<anonymous>) at TemplateArchiveProcessor.trigger (.../template-engine/lib/TemplateArchiveProcessor.js:286:36) @dselman @mttrbrts @DianaLease