Skip to content

Conversation

@stack72
Copy link
Contributor

@stack72 stack72 commented Oct 6, 2025

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:

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
}

@github-actions
Copy link

github-actions bot commented Oct 6, 2025

Dependency Review

✅ No vulnerabilities or OpenSSF Scorecard issues found.

Scanned Files

None

aaron-dernley
aaron-dernley previously approved these changes Oct 6, 2025
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?;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rgr!

@britmyerss
Copy link
Contributor

@stack72 we should add coverage of this in an integration test too if we don't have it

@stack72 stack72 force-pushed the feat-luminork-error-on-create-only branch from 37ad558 to 7e82012 Compare October 6, 2025 17:28
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
}
```
@stack72 stack72 force-pushed the feat-luminork-error-on-create-only branch from 7e82012 to a8256f7 Compare October 6, 2025 17:34
@stack72 stack72 added this pull request to the merge queue Oct 6, 2025
Merged via the queue into main with commit f21b877 Oct 6, 2025
10 checks passed
@stack72 stack72 deleted the feat-luminork-error-on-create-only branch October 6, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants