Repository navigation
Handle projects without an AOI collection - #47
Merged
Merged
Conversation
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>
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #46.
Problem
ControllerBuilder.build()looks up theRxUDIDefinitionCollectionrecord and then readsresults[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 withIndexError: list index out of range.Change
_get_aoi_records(cur, controller_id), modeled on the existing_get_program_recordshelper. The helper keeps the "more than one AOI collection" check and returns[]when the collection is absent.ControllerBuilderthen builds no AOIs, the same way a missingRxTaskCollectionorRxMapDeviceCollectionis already handled.test/test_program_collections.pyusing the in-memorycompsfixture: one with no collection, one with AOIs present.Verification
I don't have a v15 file, so I simulated one. I loaded
resources/ACDTestsWithAOI.ACDthroughExportL5x, deleted theRxUDIDefinitionCollectionrow from the extractedcompstable, then built the controller:IndexError: list index out of rangeOn the unmodified file, both versions return
['AddOnInstruction']. Runningpytestfromtest/gives 127 passed with the change versus 125 before; the difference is the 2 new tests. The 7test_unzip.pyerrors happen onmaintoo.🤖 Generated with Claude Code