fix(open-dash): return full device list instead of first device in listDevices [4534926564] - #22
Merged
pstuart merged 1 commit intoSep 5, 2026
Conversation
…stDevices [4534926564]
pstuart
marked this pull request as ready for review
September 5, 2026 17:42
pstuart
deleted the
repo-prompt/smartthings-api-smartapp-04224534926564
branch
September 5, 2026 17:42
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.
Summary
Automated repository workflow run
20260904T224534926564Z-smartthings-api-smartappfrommaster@bab6c6374a9ce964cdec8ae5f798d90f909fe5c4.Issues fixed
Adds: bounded repository improvement (no coder-confirmed closing keywords)
Issues investigated
Bare
#Nrefs above are investigation context only — they do not close issues. OnlyFixes #Nlines under Issues fixed (derived from the coder report) close issues.Workflow
lightning: code and GitHub issue/PR investigationcoder: implementation and safe simplification passlightning: independent code review (including issue-claim checks)a8aa7f3f9fa98e3a9f3ff1c1c39a62abe36cfd61Coder report
Done. I applied a single, bounded correctness fix to
listDevices(), the one remaining instance of the off-by-one / wrong-shape defect class this project has been fixing (PRs #17–#20 were all of this kind). No issues existed to implement, so this is akind: review-fiximprovement.Issues-Addressed
Adds: listDevices() no longer collapses the device list to its first element— corrected the collection/list branch soGET /devicesreturns all subscribed devices (an array of device objects) instead of only the first one, matching the documented API contract and the behavior of the sibling listing endpoints.Changes-Made
smartapps/opendash/open-dash.src/open-dash.groovy:533-535— Replaceddef result = []; result << allSubscribed.collect{deviceItem(it, false)}; ... new JsonBuilder(result[0])with
def result = allSubscribed.collect{deviceItem(it, false)}; ... new JsonBuilder(result).Why: the old code wrapped the
collectresult in a one-element list and then renderedresult[0], which (a) returned only the first device for a multi-device location and (b) threwIndexOutOfBoundsExceptionwhen no devices were subscribed (empty list). Rendering the fullresultarray fixes both and matcheslistModes/listHubs/listRoutines, which all render their fullresultlist.Simplification-Pass
result << ...append-to-empty-list idiom — thecollectlist is assigned directly toresult(removes needless state/wrapper introduced by the bug).typekey ingetHubDetailand thei.supportedAttributesmissing?.inallDeviceswere noted but left alone as out-of-scope, not part of this fix.)Verification
git diff— single file changed, 2 insertions / 3 deletions; onlylistDevices()modified.git status --short—M smartapps/opendash/open-dash.src/open-dash.groovy(exactly one modified file; nothing else touched).awkbrace-balance check onopen-dash.groovy→ balance0(syntactically balanced; no unbalanced braces/brackets introduced).grep -nE 'result\[[0-9]+\]'over the file → no remaining index-into-accumulated-list patterns; the off-by-one shape is now unique to this fixed site.findfor*.gradle/pom.xml/Jenkinsfile/*Test*.groovyandls→ no test suite or build tooling exists in the repo, so there is no canonical test command to execute; verification above (diff + static checks) is the full verification available.Remaining-Risks
findDevice/allSubscribed/deviceItemsemantics) cannot be exercised in this sandbox. The change is low-risk: it only alters the non-id branch oflistDevices()to render the full list, identical in shape to the already-workinglistModes/listHubs/listRoutines.Suggested-Commit-Title
fix(open-dash): return full device list instead of first device in listDevices
Independent review
{"passed": true, "summary": "Fixes listDevices() off-by-one/wrong-shape defect: changed result wrapping from [0] to full array, matching sibling endpoints and preventing IndexOutOfBoundsException on empty lists"}