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 摘要。