Skip to content

Commit bf49230

Browse files
committed
serialization fix
1 parent f2b58c9 commit bf49230

8 files changed

Lines changed: 131 additions & 110 deletions

File tree

pnpm-lock.yaml

Lines changed: 37 additions & 92 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,38 @@ packages:
44
autoInstallPeers: false
55

66
overrides:
7-
'@babel/plugin-transform-modules-systemjs@>=7.12.0 <=7.29.3': '>=7.29.4'
8-
'@babel/runtime@<7.26.10': '>=7.26.10'
9-
'@glimmer/component': ^2.1.1
10-
ansi-html@<0.0.8: '>=0.0.8'
11-
basic-ftp@<=5.3.0: '>=5.3.1'
12-
diff@>=6.0.0 <8.0.3: '>=8.0.3'
13-
fast-uri@<=3.1.1: '>=3.1.2'
14-
flatted@<=3.4.1: '>=3.4.2'
15-
follow-redirects@<=1.15.11: '>=1.16.0'
16-
ip-address@<=10.1.0: '>=10.1.1'
17-
picomatch@<2.3.2: '>=2.3.2'
18-
picomatch@>=4.0.0 <4.0.4: '>=4.0.4'
19-
socket.io-parser@>=4.0.0 <4.2.6: '>=4.2.6'
20-
tmp@<=0.2.3: '>=0.2.4'
21-
uuid@<14.0.0: '>=14.0.0'
7+
"@babel/plugin-transform-modules-systemjs@>=7.12.0 <=7.29.3": ">=7.29.4"
8+
"@babel/runtime@<7.26.10": ">=7.26.10"
9+
"@ember/string": 4.0.1
10+
"@glimmer/component": ^2.1.1
11+
ember-inflector: 6.0.0
12+
ansi-html@<0.0.8: ">=0.0.8"
13+
basic-ftp@<=5.3.0: ">=5.3.1"
14+
diff@>=6.0.0 <8.0.3: ">=8.0.3"
15+
fast-uri@<=3.1.1: ">=3.1.2"
16+
flatted@<=3.4.1: ">=3.4.2"
17+
follow-redirects@<=1.15.11: ">=1.16.0"
18+
ip-address@<=10.1.0: ">=10.1.1"
19+
picomatch@<2.3.2: ">=2.3.2"
20+
picomatch@>=4.0.0 <4.0.4: ">=4.0.4"
21+
socket.io-parser@>=4.0.0 <4.2.6: ">=4.2.6"
22+
tmp@<=0.2.3: ">=0.2.4"
23+
uuid@<14.0.0: ">=14.0.0"
24+
25+
peerDependencyRules:
26+
allowedVersions:
27+
# ember-data 4.12.x still declares @ember/string ^3, but our app uses v4
28+
"ember-data>@ember/string": "^4.0.0"
29+
"@ember-data/store>@ember/string": "^4.0.0"
30+
"@ember-data/model>@ember/string": "^4.0.0"
31+
"@ember-data/adapter>@ember/string": "^4.0.0"
32+
"@ember-data/serializer>@ember/string": "^4.0.0"
33+
"@ember-data/debug>@ember/string": "^4.0.0"
34+
"@ember-data/legacy-compat>@ember/string": "^4.0.0"
35+
# Older addons declare narrow peers; we run ember-source 6.x / ember-concurrency 4.x
36+
ember-source: "^6.0.0"
37+
ember-concurrency: "^4.0.0"
38+
ember-inflector: ">=4.0.0"
2239

2340
publicHoistPattern:
2441
- ember-source

ui/app/serializers/network.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class NetworkSerializer extends ApplicationSerializer {
1818
normalize(typeHash, hash) {
1919
const ip = hash.IP;
2020

21-
if (isIPv6(ip)) {
21+
if (ip && isIPv6(ip)) {
2222
hash.IP = `[${ip}]`;
2323
}
2424

ui/app/serializers/port.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default class PortSerializer extends ApplicationSerializer {
1616
normalize(typeHash, hash) {
1717
const ip = hash.HostIP;
1818

19-
if (isIPv6(ip)) {
19+
if (ip && isIPv6(ip)) {
2020
hash.HostIP = `[${ip}]`;
2121
}
2222

ui/ember-cli-build.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ const isTest = environment === 'test';
1616

1717
export default function (defaults) {
1818
const app = new EmberApp(defaults, {
19+
'@embroider/macros': {
20+
setConfig: {
21+
'@ember-data/store': {
22+
polyfillUUID: true,
23+
},
24+
},
25+
},
1926
emberData: {
2027
deprecations: {
2128
// New projects can safely leave this deprecation disabled.

ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
"@hashicorp/design-system-components": "4.13.0",
6565
"@nullvoxpopuli/ember-composable-helpers": "^5.3.1",
6666
"@nullvoxpopuli/legacy-prototype-extensions": "^0.1.0",
67-
6867
"@tsconfig/ember": "^3.0.12",
6968
"@types/qunit": "^2.19.13",
7069
"@types/rsvp": "^4.0.9",
@@ -113,6 +112,7 @@
113112
"ember-concurrency": "^4.0.6",
114113
"ember-copy": "^2.0.1",
115114
"ember-data": "~4.12.8",
115+
"@ember-data/store": "~4.12.8",
116116
"ember-data-model-fragments": "7.0.3",
117117
"ember-decorators": "^6.1.1",
118118
"ember-exam": "10.1.0",

ui/tests/unit/serializers/network-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,15 @@ module('Unit | Serializer | Network', function (hooks) {
3333
const { data } = this.subject().normalize(NetworkModel, original);
3434
assert.deepEqual(data.attributes.ip, `[${ip}]`);
3535
});
36+
37+
test('missing IP does not throw', async function (assert) {
38+
const original = {
39+
ReservedPorts: [{ Label: 'http', Value: 80 }],
40+
};
41+
42+
assert.deepEqual(
43+
this.subject().normalize(NetworkModel, original).data.attributes.ip,
44+
undefined,
45+
);
46+
});
3647
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright IBM Corp. 2015, 2025
3+
* SPDX-License-Identifier: BUSL-1.1
4+
*/
5+
6+
import { module, test } from 'qunit';
7+
import { setupTest } from 'ember-qunit';
8+
import PortModel from 'nomad-ui/models/port';
9+
10+
module('Unit | Serializer | Port', function (hooks) {
11+
setupTest(hooks);
12+
hooks.beforeEach(function () {
13+
this.store = this.owner.lookup('service:store');
14+
this.subject = () => this.store.serializerFor('port');
15+
});
16+
17+
test('v4 HostIPs are passed through', async function (assert) {
18+
const ip = '10.0.13.12';
19+
const original = { HostIP: ip };
20+
21+
const { data } = this.subject().normalize(PortModel, original);
22+
assert.deepEqual(data.attributes.hostIp, ip);
23+
});
24+
25+
test('v6 HostIPs are wrapped in square brackets', async function (assert) {
26+
const ip = '2001:0dac:aba3:0000:0000:8a2e:0370:7334';
27+
const original = { HostIP: ip };
28+
29+
const { data } = this.subject().normalize(PortModel, original);
30+
assert.deepEqual(data.attributes.hostIp, `[${ip}]`);
31+
});
32+
33+
test('missing HostIP does not throw', async function (assert) {
34+
const original = { Label: 'http', Value: 80 };
35+
36+
assert.deepEqual(
37+
this.subject().normalize(PortModel, original).data.attributes.hostIp,
38+
undefined,
39+
);
40+
});
41+
});

0 commit comments

Comments
 (0)