Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions ui/src/utils/packetTypes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,12 @@ describe('formatPacketType', () => {
).toBe('Raw Video (1920x1080, Rgba8)');
});

it('renders null-valued RawVideo fields literally (template renderer ignores null wildcard_value)', () => {
// See PR follow-up note: `formatWithTemplate` short-circuits when the meta's
// `wildcard_value` is null, so null-valued fields render as the literal string "null"
// rather than "*". `canConnectPair` does NOT have this asymmetry — it correctly
// treats null as a valid wildcard. This test pins the current behavior; do not
// change the assertion without also auditing the renderer.
it('renders null-valued RawVideo wildcard fields as *', () => {
expect(
formatPacketType({
RawVideo: { width: null, height: null, pixel_format: 'Rgba8' },
})
).toBe('Raw Video (nullxnull, Rgba8)');
).toBe('Raw Video (*x*, Rgba8)');
});

it('renders the Custom template with the supplied type_id', () => {
Expand Down
5 changes: 2 additions & 3 deletions ui/src/utils/packetTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ function formatWithTemplate(
let isWildcard = false;
if (compat && compat.kind === 'structfieldwildcard') {
const rule = compat.fields.find((f) => f.name === field);
const wildcard = rule?.wildcard_value;
if (wildcard !== undefined && wildcard !== null) {
isWildcard = deepEqual(value, wildcard);
if (rule && 'wildcard_value' in rule) {
isWildcard = deepEqual(value, rule.wildcard_value);
Comment on lines +39 to +40
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Null wildcards render as * even when the template did not request wildcard display

formatWithTemplate now treats any field rule that has wildcard_value: null as display-wildcarded, but the replacement callback still ignores whether the placeholder was written as {field|*} or plain {field}. The packet metadata contract says the |* suffix is what indicates wildcard display (crates/core/src/packet_meta.rs:46-48), so server/plugin metadata that includes a nullable wildcard field in a normal {field} placeholder will now render * instead of the literal field value. The built-in RawVideo dimensions happen to use {width|*}/{height|*}, but this shared formatter no longer honors the template syntax for null wildcards.

Suggested change
if (rule && 'wildcard_value' in rule) {
isWildcard = deepEqual(value, rule.wildcard_value);
if (rule && 'wildcard_value' in rule && _m.includes('|*')) {
isWildcard = deepEqual(value, rule.wildcard_value);
Open in Devin Review (Staging)

Was this helpful? React with 👍 or 👎 to provide feedback.

Debug

Playground

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a regression — the old code also never checked the |* capture group. The pre-existing regex (\|\*)? captures it but neither the old nor the new code uses it.

In practice this doesn't affect any current type: all fields with wildcard_value: null that appear in templates already use {field|*} (width, height, sample_rate, channels). Fields with null wildcards that don't use |* (codec_private, bitstream_format, profile, level) aren't referenced in any template.

Honoring |* would be a valid hardening for future extensibility but is a separate concern from fixing the null-exclusion bug. Happy to add it in a follow-up if the maintainer wants it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #463 to track the |* suffix check as a follow-up.

}
}
if (isWildcard) return '*';
Expand Down
Loading