Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#248 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
tooling

Research direction

Start with python/rpdk/python/templates/models.py and reproduce the failure with cfn test -- -k contract_create_delete, using the workaround described in issue 247. Compare the corresponding set_or_none implementations in hook_models.py and target_model.py. Done means generated classes can deserialize the default Tags array without the reported TypeError.

Written by the indexing model from the issue text.

Description

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.
Dominant language
Python
Stars
107
Forks
46
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws-cloudformation/cloudformation-cli-python-plugin

All issues in aws-cloudformation/cloudformation-cli-python-plugin

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.