Skip to content

fix: guard detail dict access in render.py and suppress repeated plugin load warnings#177

Open
xliry wants to merge 2 commits intopeteromallet:mainfrom
xliry:task-210-lota-1
Open

fix: guard detail dict access in render.py and suppress repeated plugin load warnings#177
xliry wants to merge 2 commits intopeteromallet:mainfrom
xliry:task-210-lota-1

Conversation

@xliry
Copy link

@xliry xliry commented Mar 1, 2026

Summary

Fixes two reported issues:

Fix #176 — AttributeError crash in desloppify next

_render_item in app/commands/next_parts/render.py assumes item['detail'] is always a dict, but it can be a string when findings come from certain scan states. This causes:

AttributeError: 'str' object has no attribute 'get'

Added a _item_detail(item) helper that always returns a dict (returning {} for strings/None/missing), and replaced all four item.get("detail", {}) call sites with it.

Fix #172 — Repeated plugin load-failure warnings on every command

Plugin load errors were re-logged on every subsequent load_all() call. This caused noisy output like:

Language plugin .clojure failed to load: ImportError: cannot import name 'generic_lang' from partially initialized module ...

appearing before normal command output on every invocation.

Changes:

  • Removed the _report_load_errors_for_load_all() call from the early-return path in load_all() — errors are now logged only once (on the initial load)
  • Added a second-pass retry for plugins that failed due to circular-import errors — after the first pass all framework modules (e.g. generic.py) are fully initialised, so the retry typically succeeds

Test plan

  • desloppify next no longer crashes with AttributeError when a finding has a string detail field
  • Plugin load warnings appear at most once per process
  • python3 -m pytest desloppify/tests/lang/common/test_lang_discovery.py — all 4 tests pass

Fixes #176
Fixes #172

xliry and others added 2 commits February 28, 2026 20:34
…mallet#78)

Adds --by-language flag to scan and status subcommands that generates
per-language score sections and scorecard images for mixed-language repos.

Changes:
- languages/_framework/resolution.py: add discover_repo_languages() helper
  that returns {lang: file_count} for all detected languages in a project
- engine/_state/schema.py: add optional dimension_scores_by_language field
  to StateModel (backwards-compatible, default absent)
- app/cli_support/parser_groups.py: add --by-language to scan + status parsers
- app/commands/scan/scan_reporting_by_language.py: new module with
  show_per_language_score_blocks() for per-language CLI score output
- app/commands/scan/scan.py: add by-language execution phase that:
  * detects all languages (requires >=2)
  * runs scan generation per language in an isolated temp state
  * stores dimension_scores_by_language in state
  * prints per-language score blocks
  * emits per-language scorecard PNGs (scorecard-{lang}.png or {lang} template)
- app/output/scorecard.py: add language kwarg to generate_scorecard() —
  when set, uses that language's dimension scores from state
- app/commands/status_cmd.py: --by-language reads stored per-language scores
  and prints them before the aggregate dimension table; JSON output includes
  dimension_scores_by_language when present

Closes: peteromallet#140

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rnings (#210)

Fix peteromallet#176: _render_item crashes with AttributeError when item['detail'] is a
string instead of a dict. Add _item_detail() helper that always returns a
dict, replacing all four item.get("detail", {}) call sites.

Fix peteromallet#172: plugin load failures are re-logged on every subsequent load_all()
call. Remove the _report_load_errors_for_load_all() call from the early-return
path so errors are only emitted once. Also add a second-pass retry for plugins
that failed due to circular-import errors — after the first pass all framework
modules are fully initialised so the retry typically succeeds.
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.

Crash in desloppify next: AttributeError in render.py Intermittent plugin loader circular-import errors in editable install

1 participant