Resource type handler_update fails to delete the right model version
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 1/5
- Geschätzter Aufwand
- Unter einer Stunde
- Anfängerfreundlichkeit
- 45/100
Rechercherichtung
Beginne in src/rpdk/core/contract/suite/resource/handler_update.py bei updated_resource und verfolge, welches Modell während des erfolgreichen Updates bis zur abschließenden Bereinigung beibehalten wird. Führe die relevante Contract-Suite für den Ressourcentyp aus und bestätige, dass die Bereinigung das vom Update zurückgegebene Modell verwendet, einschließlich Ressourcen, die optimistisches Versions-Locking erzwingen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
The updated_resource in handler_update resource type test suite is wrongly deleting the created model in its finally section instead of the potentially updated model.
My resource type is maintaining a Version field on the server with optimistic locking to avoid accidental overwrite of the resource. Upon a successful update, the version is auto-incremented and the new version is returned to the client. The client specifies the version in the If-Match header of the HTTP request, and the server allows the mutation only if the version stored is the same.
In the following function:
def updated_resource(resource_client):
create_request = input_model = resource_client.generate_create_example()
model = {}
try:
_status, response, _error = resource_client.call_and_assert(
Action.CREATE, OperationStatus.SUCCESS, create_request
)
created_model = model = response["resourceModel"]
test_input_equals_output(resource_client, input_model, created_model)
update_request = resource_client.generate_update_example(created_model)
_status, response, _error = resource_client.call_and_assert(
Action.UPDATE, OperationStatus.SUCCESS, update_request, created_model
)
updated_model = response["resourceModel"]
test_input_equals_output(resource_client, update_request, updated_model)
# flake8: noqa: B950
# pylint: disable=C0301
yield create_request, created_model, update_request, updated_model, update_request
finally:
resource_client.call_and_assert(Action.DELETE, OperationStatus.SUCCESS, model)
The following call to update:
_status, response, _error = resource_client.call_and_assert(
Action.UPDATE, OperationStatus.SUCCESS, update_request, created_model
)
updated_model = response["resourceModel"]
increments the resource version but the delete is made on the original model, which in my case, has the previous version, and thus fails:
finally:
resource_client.call_and_assert(Action.DELETE, OperationStatus.SUCCESS, model)
A potential fix, is to update the model upon successful update:
_status, response, _error = resource_client.call_and_assert(
Action.UPDATE, OperationStatus.SUCCESS, update_request, created_model
)
model = updated_model = response["resourceModel"]
When trying to delete the resource in the finally section now, the right model is provided
- Vorherrschende Sprache
- Python
- Sterne
- 336
- Forks
- 173
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus aws-cloudformation/cloudformation-cli
-
docs: `--use-docker` and `--no-docker` options of `cfn submit` are missing from the documentationOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 92/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
aws-cloudformation/cloudformation-cli#1117 · 1 Kommentar · 6 Reaktionen ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
aws-cloudformation/cloudformation-cli#1115 · 1 Kommentar · 9 Reaktionen ·
Alle Issues in aws-cloudformation/cloudformation-cli
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
521xueweihan/HelloGitHub#4385 ·
-
🐛 bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
pdm-project/pdm#4012 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
pollen-robotics/reachy_mini_conversation_app#611 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 91/100
aws-samples/sample-per-model-bedrock#913 ·
Maintainer antworten meist innerhalb von 1 Tag
-
lesson-submission pending-review
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
Ikalus1988/MisakaNet#5115 ·
Maintainer antworten meist innerhalb von 1 Tag