Commit b244784
authored
fix(service): handle null JSON metadata in pipeline conversion (#1134)
Because
- The pipeline conversion service was encountering protobuf syntax
errors when trying to unmarshal JSON metadata fields containing the
literal value `"null"`
- `structpb.Struct` expects a JSON object `{}` but cannot handle JSON
`null` values, causing parsing failures with error: `"proto: syntax
error (line 1:1): unexpected token null"`
- Legacy database records or direct database manipulation could result
in NULL metadata values being stored as the JSON literal `"null"`
This commit
- Adds null value checks before attempting to unmarshal metadata in both
`ConvertPipelineToPB` and `ConvertPipelineReleaseToPB` functions
- Prevents protobuf parsing errors by skipping unmarshaling when
metadata contains the JSON literal `"null"`
- Ensures metadata is only set on the protobuf object when valid JSON
objects are successfully unmarshaled
- Maintains backward compatibility while gracefully handling edge cases
with null metadata values
The fix ensures robust handling of metadata fields across different
scenarios:
- NULL database values (handled by skipping null literals)
- Empty metadata (handled by existing nil checks)
- Valid JSON objects (unmarshaled successfully as before)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Avoid unmarshalling JSON "null" metadata and only set `Metadata` on
protobuf when valid, for both pipelines and releases.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
f59431b. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 174f7d6 commit b244784
2 files changed
+20
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
641 | 641 | | |
642 | 642 | | |
643 | 643 | | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | | - | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
648 | 654 | | |
649 | | - | |
650 | 655 | | |
651 | 656 | | |
652 | 657 | | |
| |||
813 | 818 | | |
814 | 819 | | |
815 | 820 | | |
816 | | - | |
817 | | - | |
818 | | - | |
819 | | - | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
820 | 830 | | |
821 | | - | |
822 | 831 | | |
823 | 832 | | |
824 | 833 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1452 | 1452 | | |
1453 | 1453 | | |
1454 | 1454 | | |
| 1455 | + | |
1455 | 1456 | | |
1456 | 1457 | | |
1457 | 1458 | | |
| |||
0 commit comments