When using OOTB CFN Test is broken with 'Tags' attribute on generated class

未關閉
#248 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
python
領域
tooling

研究方向

從 python/rpdk/python/templates/models.py 開始,使用 issue 247 中描述的替代方案,透過 cfn test -- -k contract_create_delete 重現失敗。比較 hook_models.py 和 target_model.py 中對應的 set_or_none 實作。完成的標準是產生的類別能夠在不出現所回報的 TypeError 的情況下反序列化預設的 Tags 陣列。

由索引模型根據 Issue 內容生成。

描述

Assuming same steps in https://github.com/aws-cloudformation/cloudformation-cli-python-plugin/issues/247, using the workaround to get by the current cryptography issue.

After trying to run one test cfn test -- -k contract_create_delete, it fails with:

Traceback (most recent call last):
  File "/var/task/cloudformation_cli_python_lib/resource.py", line 165, in _cast_resource_request
    return UnmodelledRequest(
  File "/var/task/cloudformation_cli_python_lib/utils.py", line 156, in to_modelled
    desiredResourceState=model_cls._deserialize(self.desiredResourceState),
  File "/var/task/dd_dd_dd/models.py", line 74, in _deserialize
    Tags=set_or_none(json_data.get("Tags")),
  File "/var/task/dd_dd_dd/models.py", line 30, in set_or_none
    return set(value)
TypeError: unhashable type: 'dict'

Root cause and fix:

  • The default JSON makes Tags a list/array of Tag object ("#/definitions/Tag"). A tag object then has a key and value attribute. This is not hashable
  • Fix(probably) change this line to a frozen set: return frozenset(value)
    • Also same change for hooks?
    • Maybe this one too.
主要語言
Python
星號
107
分支
46
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

aws-cloudformation/cloudformation-cli-python-plugin 的其他 Issue

查看 aws-cloudformation/cloudformation-cli-python-plugin 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。