Skip to content

Handle projects without an AOI collection - #47

Merged
hutcheb merged 1 commit into
hutcheb:mainfrom
Anai-Guo:fix/missing-aoi-collection
Sep 13, 2026
Merged

hutcheb merged 1 commit into
hutcheb:mainfrom
Anai-Guo:fix/missing-aoi-collection

Conversation

@Anai-Guo

Copy link
Copy Markdown
Contributor

Fixes #46.

Problem

ControllerBuilder.build() looks up the RxUDIDefinitionCollection record and then reads results[0][1]. It guards against more than one match but not against zero. Add-On Instructions arrived in RSLogix 5000 v16, so v15 projects have no AOI collection, and the import dies with IndexError: list index out of range.

Change

  • Move the AOI lookup into _get_aoi_records(cur, controller_id), modeled on the existing _get_program_records helper. The helper keeps the "more than one AOI collection" check and returns [] when the collection is absent. ControllerBuilder then builds no AOIs, the same way a missing RxTaskCollection or RxMapDeviceCollection is already handled.
  • The helper uses parameterized queries. The SQL itself is unchanged.
  • Adds two unit tests to test/test_program_collections.py using the in-memory comps fixture: one with no collection, one with AOIs present.

Verification

I don't have a v15 file, so I simulated one. I loaded resources/ACDTestsWithAOI.ACD through ExportL5x, deleted the RxUDIDefinitionCollection row from the extracted comps table, then built the controller:

  • before the fix: IndexError: list index out of range
  • after the fix: the controller builds with 0 AOIs, 1 program and 1 task

On the unmodified file, both versions return ['AddOnInstruction']. Running pytest from test/ gives 127 passed with the change versus 125 before; the difference is the 2 new tests. The 7 test_unzip.py errors happen on main too.

🤖 Generated with Claude Code

Add-On Instructions were introduced in RSLogix 5000 v16, so older (v15)
projects have no RxUDIDefinitionCollection record. ControllerBuilder
indexed the empty lookup result and raised IndexError, aborting the
whole import (hutcheb#46).

Move the AOI lookup into _get_aoi_records(), next to
_get_program_records(), and return no AOIs when the collection is
absent. Add unit tests for both cases.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@hutcheb
hutcheb merged commit 8f59294 into hutcheb:main Sep 13, 2026
6 checks passed
@hutcheb

hutcheb commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Thanks @Anai-Guo and @nokkies

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.

IndexError building controller when a project has no AOI collection (RSLogix 5000 v15)

2 participants