Skip to content

Commit

Permalink
Device aliases are a map, not an array
Browse files Browse the repository at this point in the history
Fix the parsing of device aliases, which
are to be parsed in the same way as attributes.

Signed-off-by: Arnaldo Cesco <arnaldo.cesco@gmail.com>
  • Loading branch information
Annopaolo committed Nov 12, 2024
1 parent a1a088d commit be88292
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.92.2] - Unreleased
### Fixed
- Parse device aliases as a map, not as an array.

## [0.92.1]- 2024-09-16
### Added
- Add template type support for trigger, thus enabling Mustache templating.
Expand Down
10 changes: 5 additions & 5 deletions client/appengine_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ func (r ListDeviceInterfacesResponse) Raw(f func(*http.Response) any) any {
}

// Parses data obtained by performing a request device's aliases.
// Returns the list of aliases as an array of strings.
// Returns the list of aliases as a map strings to strings.
func (r ListDeviceAliasesResponse) Parse() (any, error) {
defer r.res.Body.Close()
b, _ := io.ReadAll(r.res.Body)
data := gjson.GetBytes(b, "data.aliases").Array()
aliases := []string{}
for _, v := range data {
aliases = append(aliases, v.Str)
data := gjson.GetBytes(b, "data.aliases").Map()
aliases := map[string]string{}
for k, v := range data {
aliases[k] = v.Str

Check warning on line 234 in client/appengine_data.go

View check run for this annotation

Codecov / codecov/patch

client/appengine_data.go#L231-L234

Added lines #L231 - L234 were not covered by tests
}
return aliases, nil
}
Expand Down

0 comments on commit be88292

Please sign in to comment.