Skip to main content

valid-error-template-message

Overview

This rule belongs to the apimatic-codegen-validation ruleset and states that:

Value of an error template entry must be a valid string message, with support for expression templates. A template must start and end with curly braces {} and contain a valid expression in between. The templates are filled with actual data at runtime. Allowed template expression placeholders include: {$statusCode}, {$response.header.<headerKey>}, {$response.body<#JsonPointer>}. If {$response.header.<headerKey>} placeholder is used, <headerKey> must be replaced with a valid response header name. <#JsonPointer> in the {$response.body<#JsonPointer>} placeholder is an optional segment that can be used to access a particular part of a JSON response body. If used, it must follow valid JSON pointer syntax.

PropertyValue
EnabledYes
Maximum SeverityError
MessageError template message is invalid.
CodeAPIMATICCODEGEN_V502
TypeValidation
Rule SystemSemantic
Products ImpactedCode Generation, Developer Experience Portal
Tagsapimatic code generation codegen sdks portal docs validation apimatic error template template runtime expression expression errors exceptions codegen setting endpoint setting

Suggested Fixes

  • Ensure that any curly braces in the error template message are correctly balanced i.e. there are no missing starting or ending curly braces or extra braces present.
  • Make sure that reserved placeholders like $statusCode, $response.header, $response.body are correctly spelled. The placeholder names are compared in a case-sensitive manner.
  • If you are using the {$response.body<#JsonPointer>} placeholder, make sure that you are using valid JSON pointer syntax. A valid error message example for this case: An error has occurred: {$response.body#/errors/0/reason}
  • An error template is used for generating meaningful exception messages in SDKs.

For More Information