-
-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
Checking the API in Swagger, /api/config-editor/ui/plugins/hide-updates-for is a PUT call, not a GET call, therefore no values will ever be returned.
Therefore the call fails with ERR_BAD_REQUEST, because no payload is sent to the API endpoint which expects an array:
[
"homebridge-plugin-name"
]
This piece of code needs to be rethought as it is using the wrong API endpoint in the wrong way.
Looking at the code, a GET call is made to the API, so any code fix is just catching the inevitable errors generated by the bad code:
public async getIgnoredPlugins(): Promise<Array<string>> {
if (this.isConfigured()) {
try {
this.log.debug('Calling /api/config-editor/ui/plugins/hide-updates-for API endpoint')
const result = await this.makeCall('/api/config-editor/ui/plugins/hide-updates-for')
// Validate the response format
if (!Array.isArray(result)) {
this.log.warn(`Unexpected response format from ignored plugins API: ${typeof result}, expected array`)
return []
}
...
}
...
private async makeCall(apiPath: string): Promise<any[]> {
return axios
.get(this.baseUrl + apiPath, {
headers: {
Authorization: `Bearer ${this.getToken()}`,
},
httpsAgent: this.httpsAgent,
lookup: this.cacheable.lookup,
})
.then((response) => {
this.log.debug(`${this.baseUrl + apiPath}: ${JSON.stringify(response.data)}`)
if (!Array.isArray(response.data)) {
return [response.data]
}
return response.data
})
.catch((error) => {
// At this point, we should have exhausted the retries
this.log.error(`${error.code} error connecting to ${this.baseUrl + apiPath}`)
return []
})
}
The call
Metadata
Metadata
Assignees
Labels
No labels