Skip to content

Commit f13b270

Browse files
authored
Fix issue with export profile api route (#93)
The is an error calling the `GET /profiles/{name}/export` API route. The server returns `Cannot read properties of undefined (reading 'length')` error. This issue is server side so this commit attempts to work around the issue by calling the `GET /profiles/{name}` route instead for the export function. This change should be undone once the server side route is fixed. fixes #92
1 parent fe8a857 commit f13b270

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

pkg/services/profiles.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,23 @@ func (svc *ProfileService) Import(in Profile) (*Profile, error) {
220220
func (svc *ProfileService) Export(name string) (*Profile, error) {
221221
logger.Trace()
222222

223-
var res Profile
224-
var uri = fmt.Sprintf("/profiles/%s/export", name)
223+
type Response struct {
224+
Metadata Metadata `json:"metadata"`
225+
Profile *Profile `json:"profile"`
226+
}
227+
228+
var res Response
229+
230+
// XXX (privateip): The export URI returns an error from the server so
231+
// using the get profile route instead
232+
//var uri = fmt.Sprintf("/profiles/%s/export", name)
233+
var uri = fmt.Sprintf("/profiles/%s", name)
225234

226235
if err := svc.client.Get(uri, &res); err != nil {
227236
return nil, err
228237
}
229238

230-
return &res, nil
239+
return res.Profile, nil
231240
}
232241

233242
func (svc *ProfileService) Activate(name string) error {

0 commit comments

Comments
 (0)