-
Notifications
You must be signed in to change notification settings - Fork 256
feat(luminork): Error when a user tries to update a readonly property #7438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Dependency Review✅ No vulnerabilities or OpenSSF Scorecard issues found.Scanned FilesNone |
a9f2ddb to
37ad558
Compare
lib/dal/src/attribute/attributes.rs
Outdated
| let component = Component::get_by_id(ctx, component_id).await?; | ||
| if component.resource(ctx).await?.is_some() { | ||
| let prop_id = AttributeValue::prop_id(ctx, target_av_id).await?; | ||
| let prop = Prop::get_by_id(ctx, prop_id).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's switch this - first check if it's a create_only, and then, use Component::resource_by_id function as we don't need the full component here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rgr!
|
@stack72 we should add coverage of this in an integration test too if we don't have it |
37ad558 to
7e82012
Compare
When a user tries to update a read-only prop, we should throw a 412.
Trying to change the KeyName of an AWS::EC2::KeyPair as the following request:
```
curl -X 'PUT' \
'http://localhost:5380/v1/w/01HPJ3K7RC486W9RPR3T0B6HS2/change-sets/01K6WQ2YG46GJYSXFA4S58F2EX/components/01K6WPWQX5VCJ2NETCDQ433VEP' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"attributes": {
"/domain/KeyName": "updated-key-name
}
}'
```
now throws an error so that the user knows what the issue is:
```
{
"message": "attribute error: cannot update create-only property at path '/domain/KeyName' when component has a resource attached",
"statusCode": 412,
"code": null
}
```
7e82012 to
a8256f7
Compare
FIXES: BUG-1080
When a user tries to update a read-only prop, we should throw a 412.
Trying to change the KeyName of an AWS::EC2::KeyPair as the following request:
now throws an error so that the user knows what the issue is: