Enum cedar_policy_core::parser::err::ToASTError
source · #[non_exhaustive]pub enum ToASTError {
Show 53 variants
DuplicateTemplateId(PolicyID),
DuplicatePolicyId(PolicyID),
UnexpectedTemplate {
slot: Slot,
},
BadAnnotations,
SlotsInConditionClause {
slot: Slot,
clausetype: &'static str,
},
MissingScopeConstraint(Var),
ExtraHeadConstraints(VariableDef),
ReservedIdentifier(Ident),
InvalidIdentifier(String),
InvalidEffect(Ident),
InvalidCondition(Ident),
InvalidScopeConstraintVariable(Ident),
InvalidMethodName(String),
IncorrectVariable {
expected: Var,
got: Var,
},
InvalidConstraintOperator(RelOp),
InvalidScopeEqualityRHS,
InvalidActionType(EntityUID),
EmptyClause(Option<Ident>),
AnnotationInvariantViolation,
MembershipInvariantViolation,
InvalidString(String),
ArbitraryVariable(SmolStr),
InvalidAttribute(SmolStr),
InvalidAttributesInRecordLiteral,
PathAsAttribute(String),
FunctionCallOnMethod(Id),
InvalidPattern(String),
WrongNode {
expected: &'static str,
got: String,
suggestion: Option<String>,
},
AmbiguousOperators,
UnsupportedDivision,
UnsupportedModulo,
NonConstantMultiplication,
IntegerLiteralTooLarge(u64),
UnaryOpLimit(UnaryOp),
VariableCall(Var),
NoMethods(Name, Id),
NotAFunction(Name),
UnsupportedEntityLiterals,
ExpressionCall,
InvalidAccess(Name, SmolStr),
InvalidIndex(Name, SmolStr),
NonStringIndex,
DuplicateKeyInRecordLiteral {
key: SmolStr,
},
TypeConstraints,
InvalidPath,
NonNormalizedString {
kind: &'static str,
src: String,
normalized_src: String,
},
MissingNodeData,
HasNonLiteralRHS,
InvalidExpression(Name),
WrongArity {
name: &'static str,
expected: usize,
got: usize,
},
Unescape(UnescapeError),
RefCreation(RefCreationError),
InvalidIs(InvalidIsError),
}
Expand description
Errors in the CST -> AST transform, mostly well-formedness issues.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
DuplicateTemplateId(PolicyID)
Returned when we attempt to parse a template with a conflicting id
DuplicatePolicyId(PolicyID)
Returned when we attempt to parse a policy with a conflicting id
UnexpectedTemplate
Returned when a template is encountered but a static policy is expected
BadAnnotations
Returned when we attempt to parse a policy with malformed or conflicting annotations
SlotsInConditionClause
Fields
Returned when a policy contains template slots in a when/unless clause. This is not currently supported. See RFC 3
MissingScopeConstraint(Var)
Returned when a policy is missing one of the 3 required scope clauses. (principal
, action
, and resource
)
ExtraHeadConstraints(VariableDef)
Returned when a policy has an extra scope clause. This is not valid syntax
ReservedIdentifier(Ident)
Returned when a policy uses a reserved keyword as an identifier.
InvalidIdentifier(String)
Returned when a policy contains an invalid identifier.
This error is not currently returned, but is here for future-proofing.
See cst::Ident::Invalid
InvalidEffect(Ident)
Returned when a policy uses a effect keyword beyond permit
or forbid
InvalidCondition(Ident)
Returned when a policy uses a condition keyword beyond when
or unless
InvalidScopeConstraintVariable(Ident)
Returned when a policy uses a variable in the scope beyond principal
, action
, or resource
InvalidMethodName(String)
Returned when a policy contains an invalid method name
IncorrectVariable
Fields
Returned when a policy scope clause contains the wrong variable. (principal
must be in the first clause, etc…)
InvalidConstraintOperator(RelOp)
Returned when a policy scope clauses uses an operator beyond ==
or in
.
InvalidScopeEqualityRHS
Returned when the right hand side of ==
in a policy scope clause is not a single Entity UID or a template slot.
This is valid in Cedar conditions, but not in the Scope
InvalidActionType(EntityUID)
Returned when an Entity UID used as an action does not have the type Action
EmptyClause(Option<Ident>)
Returned when a condition clause is empty
AnnotationInvariantViolation
Returned when the internal invariant around annotation info has been violated
MembershipInvariantViolation
Returned when membership chains do not resolve to an expression, violating an internal invariant
InvalidString(String)
Returned for a non-parse-able string literal
ArbitraryVariable(SmolStr)
Returned for attempting to use an arbitrary variable name. Cedar does not support arbitrary variables.
InvalidAttribute(SmolStr)
Returned for attempting to use an invalid attribute name
InvalidAttributesInRecordLiteral
Returned for attempting to use an invalid attribute name in a record name
PathAsAttribute(String)
Returned for attempting to use an attribute with a namespace
FunctionCallOnMethod(Id)
Returned when a policy attempts to call a method function-style
InvalidPattern(String)
Returned when the right hand side of a like
expression is not a constant pattern literal
WrongNode
Fields
Returned when an unexpected node is in the policy scope clause
AmbiguousOperators
Returned when a policy contains ambiguous ordering of operators. This can be resolved by using parenthesis to make order explicit
UnsupportedDivision
Returned when a policy uses the division operator (/
), which is not supported
UnsupportedModulo
Returned when a policy uses the remainder/modulo operator (%
), which is not supported
NonConstantMultiplication
Returned when a policy attempts to multiply by a non-constant integer
IntegerLiteralTooLarge(u64)
Returned when a policy contains an integer literal that is out of range
UnaryOpLimit(UnaryOp)
Returned when a unary operator is chained more than 4 times in a row
VariableCall(Var)
Returned when a variable is called as a function, which is not allowed. Functions are not first class values in Cedar
NoMethods(Name, Id)
Returned when a policy attempts to call a method on a value that has no methods
NotAFunction(Name)
Returned when a policy attempts to call a function that does not exist
UnsupportedEntityLiterals
Returned when a policy attempts to write an entity literal
ExpressionCall
Returned when an expression is the target of a function call. Functions are not first class values in Cedar
InvalidAccess(Name, SmolStr)
Returned when a policy attempts to access the fields of a value with no fields
InvalidIndex(Name, SmolStr)
Returned when a policy attempts to index on a fields of a value with no fields
NonStringIndex
Returned when the contents of an indexing expression is not a string literal
DuplicateKeyInRecordLiteral
Returned when the same key appears two or more times in a single record literal
TypeConstraints
Returned when a user attempts to use type-constraint :
syntax. This
syntax was not adopted, but is
can be used to write type constraints
in the policy scope.
InvalidPath
Returned when a policy uses a path in an invalid context
NonNormalizedString
Fields
Returned when a string needs to be fully normalized
MissingNodeData
Returned when a CST node is empty
HasNonLiteralRHS
Returned when the right hand side of a has
expression is neither a field name or a string literal
InvalidExpression(Name)
Returned when a CST expression is invalid
WrongArity
Fields
Returned when a function has wrong arity
Unescape(UnescapeError)
Returned when a string contains invalid escapes
RefCreation(RefCreationError)
Returns when a policy scope has incorrect EntityUIDs/Template Slots
InvalidIs(InvalidIsError)
Returned when an is
appears in an invalid position in the policy scope
Implementations§
source§impl ToASTError
impl ToASTError
sourcepub fn wrong_node(
expected: &'static str,
got: impl Into<String>,
suggestion: Option<impl Into<String>>
) -> Self
pub fn wrong_node( expected: &'static str, got: impl Into<String>, suggestion: Option<impl Into<String>> ) -> Self
Constructor for the ToASTError::WrongNode
error
sourcepub fn wrong_arity(name: &'static str, expected: usize, got: usize) -> Self
pub fn wrong_arity(name: &'static str, expected: usize, got: usize) -> Self
Constructor for the ToASTError::WrongArity
error
Trait Implementations§
source§impl Clone for ToASTError
impl Clone for ToASTError
source§fn clone(&self) -> ToASTError
fn clone(&self) -> ToASTError
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ToASTError
impl Debug for ToASTError
source§impl Diagnostic for ToASTError
impl Diagnostic for ToASTError
source§fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic
. Ideally also globally unique, and documented
in the toplevel crate’s documentation for easy searching. Rust path
format (foo::bar::baz
) is recommended, but more classic codes like
E0123
or enums will work just fine.source§fn severity(&self) -> Option<Severity>
fn severity(&self) -> Option<Severity>
ReportHandler
s to change the display format
of this diagnostic. Read moresource§fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic
. Do you have any
advice for the poor soul who’s just run into this issue?source§fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic
.source§fn source_code(&self) -> Option<&dyn SourceCode>
fn source_code(&self) -> Option<&dyn SourceCode>
Diagnostic
’s Diagnostic::labels
to.source§fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
Diagnostic
’s Diagnostic::source_code
Diagnostic
s.source§fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
source§impl Display for ToASTError
impl Display for ToASTError
source§impl Error for ToASTError
impl Error for ToASTError
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
source§impl From<InvalidIsError> for ToASTError
impl From<InvalidIsError> for ToASTError
source§fn from(source: InvalidIsError) -> Self
fn from(source: InvalidIsError) -> Self
source§impl From<RefCreationError> for ToASTError
impl From<RefCreationError> for ToASTError
source§fn from(source: RefCreationError) -> Self
fn from(source: RefCreationError) -> Self
source§impl From<ToASTError> for ParseError
impl From<ToASTError> for ParseError
source§fn from(source: ToASTError) -> Self
fn from(source: ToASTError) -> Self
source§impl PartialEq for ToASTError
impl PartialEq for ToASTError
source§fn eq(&self, other: &ToASTError) -> bool
fn eq(&self, other: &ToASTError) -> bool
self
and other
values to be equal, and is used
by ==
.