File tree Expand file tree Collapse file tree 3 files changed +73
-1
lines changed
cedar-policy-validator/src Expand file tree Collapse file tree 3 files changed +73
-1
lines changed Original file line number Diff line number Diff line change @@ -1972,4 +1972,72 @@ mod test {
1972
1972
"ExampleCo::Personnel::Action"
1973
1973
) ;
1974
1974
}
1975
+
1976
+ #[ test]
1977
+ fn qualified_undeclared_common_types ( ) {
1978
+ let src = json ! (
1979
+ {
1980
+ "Demo" : {
1981
+ "entityTypes" : {
1982
+ "User" : {
1983
+ "memberOfTypes" : [ ] ,
1984
+ "shape" : {
1985
+ "type" : "Record" ,
1986
+ "attributes" : {
1987
+ "id" : { "type" : "id" } ,
1988
+ }
1989
+ }
1990
+ }
1991
+ } ,
1992
+ "actions" : { }
1993
+ } ,
1994
+ "" : {
1995
+ "commonTypes" : {
1996
+ "id" : {
1997
+ "type" : "String"
1998
+ } ,
1999
+ } ,
2000
+ "entityTypes" : { } ,
2001
+ "actions" : { }
2002
+ }
2003
+ }
2004
+ ) ;
2005
+ let schema = ValidatorSchema :: from_json_value ( src, Extensions :: all_available ( ) ) ;
2006
+ assert_matches ! ( schema, Err ( SchemaError :: UndeclaredCommonTypes ( types) ) =>
2007
+ assert_eq!( types, HashSet :: from( [ "Demo::id" . to_string( ) ] ) ) ) ;
2008
+ }
2009
+
2010
+ #[ test]
2011
+ fn qualified_undeclared_common_types2 ( ) {
2012
+ let src = json ! (
2013
+ {
2014
+ "Demo" : {
2015
+ "entityTypes" : {
2016
+ "User" : {
2017
+ "memberOfTypes" : [ ] ,
2018
+ "shape" : {
2019
+ "type" : "Record" ,
2020
+ "attributes" : {
2021
+ "id" : { "type" : "Demo::id" } ,
2022
+ }
2023
+ }
2024
+ }
2025
+ } ,
2026
+ "actions" : { }
2027
+ } ,
2028
+ "" : {
2029
+ "commonTypes" : {
2030
+ "id" : {
2031
+ "type" : "String"
2032
+ } ,
2033
+ } ,
2034
+ "entityTypes" : { } ,
2035
+ "actions" : { }
2036
+ }
2037
+ }
2038
+ ) ;
2039
+ let schema = ValidatorSchema :: from_json_value ( src, Extensions :: all_available ( ) ) ;
2040
+ assert_matches ! ( schema, Err ( SchemaError :: UndeclaredCommonTypes ( types) ) =>
2041
+ assert_eq!( types, HashSet :: from( [ "Demo::id" . to_string( ) ] ) ) ) ;
2042
+ }
1975
2043
}
Original file line number Diff line number Diff line change @@ -722,7 +722,9 @@ impl ValidatorNamespaceDef {
722
722
. map_err ( SchemaError :: ParseCommonType ) ?;
723
723
Ok ( WithUnresolvedTypeDefs :: new ( move |typ_defs| {
724
724
typ_defs. get ( & defined_type_name) . cloned ( ) . ok_or (
725
- SchemaError :: UndeclaredCommonTypes ( HashSet :: from ( [ type_name. to_string ( ) ] ) ) ,
725
+ SchemaError :: UndeclaredCommonTypes ( HashSet :: from ( [
726
+ defined_type_name. to_string ( )
727
+ ] ) ) ,
726
728
)
727
729
} ) )
728
730
}
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ Cedar Language Version: 3.1.0
22
22
23
23
### Changed
24
24
25
+ - Changed error message on ` SchemaError::UndeclaredCommonTypes ` to report
26
+ fully qualified type names. (#652 , resolving #580 )
25
27
- Better integration with ` miette ` for various error types. If you have
26
28
previously been just using the ` Display ` trait to get the error message from a
27
29
Cedar error type, you may want to consider also examining other data provided
You can’t perform that action at this time.
0 commit comments