Skip to content

Commit 1ecb931

Browse files
Fix proto roundtripping
1 parent ce5e89f commit 1ecb931

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

cedar-policy/src/proto/policy.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,7 @@ impl From<&models::TemplateBody> for ast::TemplateBody {
143143
.as_ref()
144144
.expect("resource_constraint field should exist"),
145145
),
146-
Some(ast::Expr::from(
147-
v.non_scope_constraints
148-
.as_ref()
149-
.expect("non_scope_constraints field should exist"),
150-
)),
146+
v.non_scope_constraints.as_ref().map(|e| ast::Expr::from(e)),
151147
)
152148
}
153149
}
@@ -170,11 +166,7 @@ impl From<&ast::TemplateBody> for models::TemplateBody {
170166
resource_constraint: Some(models::PrincipalOrResourceConstraint::from(
171167
v.resource_constraint(),
172168
)),
173-
non_scope_constraints: Some(
174-
v.non_scope_constraints()
175-
.map(|e| models::Expr::from(e))
176-
.unwrap_or_else(|| models::Expr::from(&ast::Expr::val(true))),
177-
),
169+
non_scope_constraints: v.non_scope_constraints().map(|e| models::Expr::from(e)),
178170
}
179171
}
180172
}

0 commit comments

Comments
 (0)