Skip to content

Conversation

@pcman312
Copy link
Contributor

@pcman312 pcman312 commented Nov 21, 2025

K8SPG-907 Powered by Pull Request Badge


Problem:
Closes #1356
There's a panic when marshalling the PITRestoreDateTime struct to JSON if the variable isn't a pointer. See the issue for a full breakdown.

Cause:
The MarshalJSON function is on a pointer receiver so json.Marshal skips over it and calls the MarshalText function on metav1.Time instead which panics on a nil receiver.

Solution:
Moves MarshalJSON onto a non-pointer receiver which Go will use for both non-pointer and pointer variables. I also added unit tests for this marshalling. I did not look at any other objects in the package to see if they have a similar problem.

CHECKLIST

Jira
No JIRA cards were created or managed, just the github issue referenced above

Tests

  • Are unit tests added where appropriate?

Config/Logging/Testability
I don't believe any of these apply to this PR

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PG version?
  • Does the change support oldest and newest supported Kubernetes version?

@it-percona-cla
Copy link

it-percona-cla commented Nov 21, 2025

CLA assistant check
All committers have signed the CLA.

@JNKPercona
Copy link
Collaborator

Test Name Result Time
backup-enable-disable passed 00:09:42
custom-envs passed 00:20:15
custom-extensions passed 00:14:22
custom-tls passed 00:05:07
database-init-sql passed 00:02:23
demand-backup passed 00:24:30
finalizers passed 00:03:38
init-deploy passed 00:02:48
monitoring passed 00:07:35
monitoring-pmm3 passed 00:09:56
one-pod passed 00:06:01
operator-self-healing passed 00:08:05
pgvector-extension passed 00:02:39
pitr passed 00:11:22
scaling passed 00:05:14
scheduled-backup passed 00:27:58
self-healing passed 00:10:14
sidecars passed 00:02:41
start-from-backup passed 00:11:04
tablespaces passed 00:06:36
telemetry-transfer passed 00:03:45
upgrade-consistency passed 00:07:58
upgrade-minor passed 00:05:55
users passed 00:04:24
Summary Value
Tests Run 24/24
Job Duration 01:36:29
Total Test Time 03:34:23

commit: bf7608b
image: perconalab/percona-postgresql-operator:PR-1368-bf7608b80

@egegunes egegunes added this to the v2.9.0 milestone Nov 24, 2025
@hors hors changed the title Fix panic on JSON marshal if PITRestoreDateTime is not a pointer K8SPG-907 Fix panic on JSON marshal if PITRestoreDateTime is not a pointer Dec 1, 2025
@hors hors merged commit 674c26a into percona:main Dec 1, 2025
10 of 13 checks passed
@hors
Copy link
Collaborator

hors commented Dec 1, 2025

@pcman312 thank you for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PITRestoreDateTime panics when marshalling to JSON

6 participants