Skip to content

Commit a6e8850

Browse files
committed
fix: Add omitempty for proper latency type
This was causing an error on the frontend, because this value can be nil!
1 parent 2e1db6c commit a6e8850

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

codersdk/workspaceresources.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type WorkspaceAgent struct {
5959
Version string `json:"version"`
6060
Apps []WorkspaceApp `json:"apps"`
6161
// DERPLatency is mapped by region name (e.g. "New York City", "Seattle").
62-
DERPLatency map[string]DERPRegion `json:"latency"`
62+
DERPLatency map[string]DERPRegion `json:"latency,omitempty"`
6363
}
6464

6565
type WorkspaceAgentResourceMetadata struct {

site/src/api/typesGenerated.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ export interface WorkspaceAgent {
536536
readonly directory?: string
537537
readonly version: string
538538
readonly apps: WorkspaceApp[]
539-
readonly latency: Record<string, DERPRegion>
539+
readonly latency?: Record<string, DERPRegion>
540540
}
541541

542542
// From codersdk/workspaceagents.go

site/src/components/Resources/ResourceAgentLatency.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface ResourceAgentLatencyProps {
1010

1111
export const ResourceAgentLatency: React.FC<ResourceAgentLatencyProps> = (props) => {
1212
const styles = useStyles()
13-
if (Object.keys(props.latency).length === 0) {
13+
if (!props.latency || Object.keys(props.latency).length === 0) {
1414
return null
1515
}
1616
return (

0 commit comments

Comments
 (0)