Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

WriteOnlyProperty removed before calling a Delete handler - Contract tests failure due to language specific plugin

Aperta
#318 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
aws, java
Ambito
backend, testing

Direzione di ricerca

Inizia leggendo il flusso del contract test descritto nell’issue e la documentazione del resource type contract di CloudFormation collegata, soprattutto i requisiti per l’eliminazione. Poi segui dove vengono rimosse le writeOnlyProperties e dove viene validata la richiesta di eliminazione in questo plugin Java. Il lavoro è completato quando l’handler di eliminazione riceve la proprietà write-only richiesta, oppure quando la validazione delle proprietà obbligatorie viene evitata in modo appropriato, e il test contract_create_delete passa.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Hi,

My resource has a property "SchemaHandlerPackage", which is both a required property and a writeOnlyProperty. I am running contract_create_delete on my resource. The create handler is invoked and returns success after creating the resource. I return all required properties and the primary ID in the resourceModel after creating the resource.

My create handler returns IN_PROGRESS two times because it takes sometime to create the resource. For these two calls, I see the "SchemaHandlerPackage" in the response(because I return it in the intermediate response as well), something like this(in rpdk.log):

[2020-10-19T19:46:46Z] DEBUG    - Received response
{
    'status': 'IN_PROGRESS',
    'callbackContext': {removed the values here},
    'callbackDelaySeconds': 5,
    'resourceModel': {
        'Arn': 'arn:aws:cloudformation:us-west-2:336098619110:type/resource/Organization-Service-Resource17/00000033',
        'SchemaHandlerPackage': 's3: //cloudformationsampleresourcetype/organization-service-resource17.zip',
        'TypeName': 'Organization::Service::Resource17'
    }
}

But when the handler returns success, the "SchemaHandlerPackage" is disappeared from the response, even though I set it in the code:

[2020-10-19T19:47:32Z] DEBUG    - Received response{
    'status': 'SUCCESS',
    'callbackDelaySeconds': 0,
    'resourceModel': {
        'Arn': 'arn:aws:cloudformation:us-west-2:336098619110:type/resource/Organization-Service-Resource17/00000033',
        'Description': 'Anexampleresourceschemademonstratingsomebasicconstructsandvalidationrules.',
        'IsDefaultVersion': False,
        'LastUpdated': '2020-10-19T19: 46: 50.047Z',
        'ProvisioningType': 'FULLY_MUTABLE',
        'Schema': {},
        'SourceUrl': 'https: //github.com/aws-cloudformation/aws-cloudformation-rpdk.git',
        'TimeCreated': '2020-10-19T19: 46: 50.047Z',
        'TypeName': 'Organization::Service::Resource17',
        'VersionId': '00000033',
        'Visibility': 'PRIVATE'
    }
}

I later found out that the writeOnlyProperties are removed before framing the request to the delete handler. By doing this, the writeOnlyProperty, which is also a required property is getting removed, hence the delete handler fails due to a validation error, which results in that contract test failure.

[2020-10-19T19:48:07Z] DEBUG    - Received response
{'status': 'FAILED', 'errorCode': 'InvalidRequest', 'message': 'Model validation failed (#: required key [SchemaHandlerPackage] not found)', 'callbackDelaySeconds': 0}
[2020-10-19T19:48:08Z] DEBUG    - Caught exit recommendation

Solution: Is the "required property validation" necessary for a delete handler? Checking for a Primary Id should be enough for a delete handler as per https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-test-contract.html#resource-type-test-contract-delete Or you can remove a writeOnlyProperty only if it's not a required property.

Thanks,
Uma

Lingua principale
Java
Stelle
30
Fork
48
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aws-cloudformation/cloudformation-cli-java-plugin

Tutte le issue di aws-cloudformation/cloudformation-cli-java-plugin

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.