Skip to content

Point azure/databases.py at the directory its icons ship in - #211

Closed
vasanth064 wants to merge 1 commit into
patrickchugh:mainfrom
vasanth064:fix/azure-databases-icon-dir
Closed

Point azure/databases.py at the directory its icons ship in#211
vasanth064 wants to merge 1 commit into
patrickchugh:mainfrom
vasanth064:fix/azure-databases-icon-dir

Conversation

@vasanth064

Copy link
Copy Markdown

Problem

resource_classes/azure/databases.py declares:

_icon_dir = "resource_images/azure/database"

but every icon the module names ships under resource_images/azure/databases. 41 of its 45 icon classes resolve to a file that does not exist. The 4 that work do so only because a same-named file happens to exist in the singular directory.

Nothing reports this. The alias resolves, so the renderer believes it has an icon and draws an empty node — no no icon for ... warning is emitted. That makes it invisible unless you look at the rendered diagram.

Why it affects modules other than this one

modules/drawing.py loads every module in the package into one namespace:

for _, module_name, _ in pkgutil.iter_modules([str(package_path)]):
    module = importlib.import_module(full_module_name)
    for name in dir(module):
        if not name.startswith("_"):
            globals()[name] = obj

Last module wins, and databases sorts after database. So databases.py overrides the aliases in database.py — including azurerm_redis_cache and azurerm_postgresql_flexible_server, which database.py maps to CacheForRedis and DatabaseForPostgresqlServers, both of whose icons are present and correct.

Net effect: Redis and PostgreSQL Flexible Server render as blank boxes in every Azure diagram, despite having working aliases and icons.

Change

One character: database to databases on line 6.

Tests

Adds tests/test_azure_icon_dirs.py, which walks every class in resource_classes.azure declaring an _icon and asserts the file exists. This catches the whole class of bug, not just this instance.

  • With the fix: 1031 passed
  • Reverting only the _icon_dir line: 41 failed, 990 passed — exactly the classes in this module
  • poetry run pytest tests -q -m "not slow" — 1698 passed, 5 deselected
  • poetry run black --check modules — 35 files unchanged

Relationship to #210

Independent. #210 adds missing Terraform aliases for Static Web Apps and Front Door; this fixes a wrong icon directory. Both branches are cut from main and neither depends on the other.

AI assistance disclosed

Per CONTRIBUTING: this change was written with AI assistance (Claude). I reviewed the diff, and the counts above come from running the commands locally rather than being estimated.

_icon_dir read resource_images/azure/database while every icon the module
names ships under resource_images/azure/databases. 41 of its 45 classes
resolved to a file that does not exist.

Nothing reported this. The alias resolved, so the renderer believed it had
an icon and drew an empty node instead of warning.

modules.drawing loads every module in the package into a single namespace,
so the alphabetically last module wins. databases.py therefore overrode the
working aliases in database.py, which is why azurerm_redis_cache and
azurerm_postgresql_flexible_server rendered blank even though database.py
mapped both to classes whose icons are present.

Adds tests/test_azure_icon_dirs.py, which asserts every Azure class with an
_icon points at a file that exists. It fails on exactly those 41 classes
without this change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vasanth064

Copy link
Copy Markdown
Author

Folded into #210. Both changes fix the same user-visible problem — Azure resources rendering without icons that already ship with Terravision — so they read better as one review than two. No content lost: the _icon_dir fix and its test are in #210 unchanged.

@vasanth064 vasanth064 closed this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant