Skip to content

Commit bced7ef

Browse files
#334: remove JSON as recommended codec for new v2 workflows
BackendCapabilities: diagnostic messages no longer suggest json as an option for new runs — only avro. CodecRegistry::engineSpecific(): json excluded from php-specific list (it is language-neutral, kept for decode only). Tests updated to reflect json is no longer universal in v2.
1 parent 04a9c84 commit bced7ef

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/Serializers/CodecRegistry.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ public static function engineSpecific(): array
139139
{
140140
$universal = self::universal();
141141

142-
$phpOnly = array_values(array_diff(array_keys(self::CODECS), $universal));
142+
// Exclude both universal codecs and json (language-neutral, kept for
143+
// decode of existing data but not advertised as engine-specific).
144+
$excluded = array_merge($universal, ['json']);
145+
$phpOnly = array_values(array_diff(array_keys(self::CODECS), $excluded));
143146

144147
if ($phpOnly === []) {
145148
return [];

src/V2/Support/BackendCapabilities.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ private static function codec(): array
279279
.'("%s") and the legacy PHP-only codecs ("workflow-serializer-y", "workflow-serializer-base64") '
280280
.'are resolvable. '
281281
.'To migrate a v1 deployment that used a custom serializer, choose one of: '
282-
.'(a) set workflows.serializer to "avro" or "json" for new runs and accept that '
282+
.'(a) set workflows.serializer to "avro" for new runs and accept that '
283283
.'old history written under the custom codec becomes unreadable, '
284284
.'(b) keep the custom serializer classes loaded and re-encode old history to a '
285285
.'supported codec before upgrading, '
@@ -304,7 +304,7 @@ private static function codec(): array
304304
'warning',
305305
'codec_legacy_php_only',
306306
sprintf(
307-
'workflows.serializer is set to [%s], a PHP-only legacy codec. New v2 workflows written with this codec cannot be decoded by Python, Go, or TypeScript workers. Set workflows.serializer to "json" for polyglot compatibility; keep the legacy codec only if you still need to read v1 history with it.',
307+
'workflows.serializer is set to [%s], a PHP-only legacy codec. New v2 workflows written with this codec cannot be decoded by Python, Go, or TypeScript workers. Set workflows.serializer to "avro" for polyglot compatibility; keep the legacy codec only if you still need to read v1 history with it.',
308308
$canonical,
309309
),
310310
);

tests/Unit/V2/BackendCapabilitiesTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,15 @@ public function testQueueModeStillRejectsSyncQueueDriver(): void
208208
$this->assertSame('error', $queueIssue['severity']);
209209
}
210210

211-
public function testDefaultJsonCodecIsUniversalAndHasNoIssues(): void
211+
public function testJsonCodecIsNotUniversalInV2(): void
212212
{
213213
config()->set('workflows.serializer', 'json');
214214

215215
$snapshot = BackendCapabilities::snapshot();
216216

217217
$this->assertSame('json', $snapshot['codec']['canonical']);
218-
$this->assertTrue($snapshot['codec']['universal']);
218+
$this->assertFalse($snapshot['codec']['universal']);
219219
$this->assertTrue($snapshot['codec']['supported']);
220-
$this->assertEmpty($snapshot['codec']['issues']);
221-
$this->assertNull(
222-
collect($snapshot['issues'])->firstWhere('component', 'codec'),
223-
);
224220
}
225221

226222
public function testLegacyPhpCodecEmitsPolyglotCompatibilityWarning(): void
@@ -281,7 +277,7 @@ public function testUnknownCodecDiagnosticIncludesMigrationGuidance(): void
281277

282278
// It must name the universal codec options an operator can migrate to.
283279
$this->assertStringContainsString('avro', $codecIssue['message']);
284-
$this->assertStringContainsString('json', $codecIssue['message']);
280+
// json is no longer recommended for new workflows (Avro-only per #334)
285281

286282
// It must mention that default-codec resolution silently falls back
287283
// to avro so operators understand why new runs still work — and that

0 commit comments

Comments
 (0)