Enum cedar_policy_core::parser::err::ToASTErrorKind
source · #[non_exhaustive]pub enum ToASTErrorKind {
Show 57 variants
DuplicateTemplateId(PolicyID),
DuplicatePolicyId(PolicyID),
UnexpectedTemplate {
slot: Slot,
},
DuplicateAnnotation(AnyId),
SlotsInConditionClause {
slot: Slot,
clausetype: &'static str,
},
MissingScopeConstraint(Var),
ExtraHeadConstraints(VariableDef),
ReservedIdentifier(Ident),
InvalidIdentifier(String),
InvalidSingleEq,
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),
MethodCallOnFunction(Id),
InvalidPattern(String),
IsInvalidName(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),
InvalidSlot(SmolStr),
}
Expand description
Details about a particular kind of ToASTError
.
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
DuplicateAnnotation(AnyId)
Returned when we attempt to parse a policy or template with duplicate 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
InvalidSingleEq
Returned when a policy uses ‘=’ as a binary operator. ‘=’ is not an operator in Cedar; we can suggest ‘==’ instead.
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 clause uses an operator not allowed in scopes.
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
MethodCallOnFunction(Id)
Returned when a policy attempts to call a function in the method style
InvalidPattern(String)
Returned when the right hand side of a like
expression is not a constant pattern literal
IsInvalidName(String)
Returned when the right hand side of a is
expression is not an entity type name
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 or method is called with the 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
InvalidSlot(SmolStr)
Returned when a policy contains a template slot other than ?principal
or ?resource
Implementations§
source§impl ToASTErrorKind
impl ToASTErrorKind
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 ToASTErrorKind::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 ToASTErrorKind::WrongArity
error
Trait Implementations§
source§impl Clone for ToASTErrorKind
impl Clone for ToASTErrorKind
source§fn clone(&self) -> ToASTErrorKind
fn clone(&self) -> ToASTErrorKind
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ToASTErrorKind
impl Debug for ToASTErrorKind
source§impl Diagnostic for ToASTErrorKind
impl Diagnostic for ToASTErrorKind
source§fn code(&self) -> Option<Box<dyn Display + '_>>
fn code(&self) -> Option<Box<dyn Display + '_>>
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 help(&self) -> Option<Box<dyn Display + '_>>
fn help(&self) -> Option<Box<dyn Display + '_>>
Diagnostic
. Do you have any
advice for the poor soul who’s just run into this issue?source§fn severity(&self) -> Option<Severity>
fn severity(&self) -> Option<Severity>
ReportHandler
s to change the display format
of this diagnostic. Read moresource§fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
Diagnostic
’s Diagnostic::source_code
source§fn source_code(&self) -> Option<&dyn SourceCode>
fn source_code(&self) -> Option<&dyn SourceCode>
Diagnostic
’s Diagnostic::labels
to.Diagnostic
s.source§fn url(&self) -> Option<Box<dyn Display + '_>>
fn url(&self) -> Option<Box<dyn Display + '_>>
Diagnostic
.source§fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
source§impl Display for ToASTErrorKind
impl Display for ToASTErrorKind
source§impl Error for ToASTErrorKind
impl Error for ToASTErrorKind
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 ToASTErrorKind
impl From<InvalidIsError> for ToASTErrorKind
source§fn from(source: InvalidIsError) -> Self
fn from(source: InvalidIsError) -> Self
source§impl From<RefCreationError> for ToASTErrorKind
impl From<RefCreationError> for ToASTErrorKind
source§fn from(source: RefCreationError) -> Self
fn from(source: RefCreationError) -> Self
source§impl From<UnescapeError> for ToASTErrorKind
impl From<UnescapeError> for ToASTErrorKind
source§fn from(source: UnescapeError) -> Self
fn from(source: UnescapeError) -> Self
source§impl PartialEq for ToASTErrorKind
impl PartialEq for ToASTErrorKind
source§fn eq(&self, other: &ToASTErrorKind) -> bool
fn eq(&self, other: &ToASTErrorKind) -> bool
self
and other
values to be equal, and is used
by ==
.