Skip to content

API views for asset-type objects get dummy "name" and "description" fields #1262

@davepacheco

Description

@davepacheco

This is easy to see when listing Sleds. You get:

$ oxide api /hardware/sleds
{
  "items": [
    {
      "description": "no description",
      "id": "fb0f7546-4d46-40ca-9d56-cbb810684ca7",
      "name": "no-name",
      "service_address": "[fd00:1122:3344:101::1]:12345",
      "time_created": "2022-06-23T22:24:05.468795Z",
      "time_modified": "2022-06-23T22:24:05.468795Z"
    }
  ],
  "next_page": "eyJ2IjoidjEiLCJwYWdlX3N0YXJ0Ijp7InNvcnRfYnkiOiJpZF9hc2NlbmRpbmciLCJsYXN0X3NlZW4iOiJmYjBmNzU0Ni00ZDQ2LTQwY2EtOWQ1Ni1jYmI4MTA2ODRjYTcifX0="
}

Notice the "name" and "description" fields. Sleds have no name or description in the database -- it looks like we cons this up here:

fn identity(&self) -> external::IdentityMetadata {
external::IdentityMetadata {
id: self.id(),
name: "no-name".parse().unwrap(),
description: "no description".to_string(),
time_created: self.time_created(),
time_modified: self.time_modified(),
}
}

This behavior seems confusing, especially since everywhere else Name appears, it's a unique identifier in its collection, but if you had a bunch of Sleds, I think they'd all have the same "name": "no-name".

I noticed this because I'm adding a view for SiloUser, which also have no name, and I'm using the same machinery, but it's particularly confusing for them to get "name": "no-name" since people might think that's a display name or something.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions