Skip to content

Commit 0a86137

Browse files
Merge pull request #91 from heroku/fix/correct-error-message-when-no-app
Corrects error message when app not found
2 parents 8378c73 + 5b693d1 commit 0a86137

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

src/commands/ai/models/info.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {flags} from '@heroku-cli/command'
33
import {Args, ux} from '@oclif/core'
44
import Command from '../../../lib/base'
55
import type {ModelResource} from '@heroku/ai'
6-
import appAddons from '../../../lib/ai/models/app_addons'
6+
77
import * as Heroku from '@heroku-cli/schema'
88

99
export default class Info extends Command {
@@ -74,7 +74,9 @@ export default class Info extends Command {
7474
} else {
7575
const provisionedModelsInfo: Record<string, string | undefined>[] = []
7676
const inferenceRegex = /inference/
77-
const addonsResponse = await appAddons(this.config, app)
77+
const {body: addonsResponse} = await this.heroku.get<Heroku.AddOn>(`/apps/${app}/addons`, {
78+
headers: {'Accept-Expansion': 'plan'},
79+
})
7880

7981
for (const addonInfo of addonsResponse as Array<Heroku.AddOn>) {
8082
const addonType = addonInfo.addon_service?.name || ''

src/lib/ai/models/app_addons.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

test/commands/ai/models/info.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,35 @@ describe('ai:models:info', function () {
168168
}
169169
})
170170
})
171+
172+
context('when app does not exist', function () {
173+
beforeEach(function () {
174+
process.env = {}
175+
api = nock('https://api.heroku.com:443')
176+
})
177+
178+
afterEach(function () {
179+
process.env = env
180+
nock.cleanAll()
181+
})
182+
183+
it('shows clean error message without addon context', async function () {
184+
api
185+
.get('/apps/nonexistent-app/addons')
186+
.reply(404, {
187+
id: 'not_found',
188+
message: 'Couldn\'t find that app.',
189+
})
190+
191+
try {
192+
await runCommand(Cmd, [
193+
'--app',
194+
'nonexistent-app',
195+
])
196+
} catch (error) {
197+
const {message} = error as CLIError
198+
expect(stripAnsi(message)).to.equal('Couldn\'t find that app.\n\nError ID: not_found')
199+
}
200+
})
201+
})
171202
})

0 commit comments

Comments
 (0)