Skip to content

Commit

Permalink
Fix unmarshalling of ScheduleSpec with null jitter
Browse files Browse the repository at this point in the history
Search attributes command: force objects in JSON
  • Loading branch information
roxblnfk committed Feb 10, 2025
1 parent e70ae3b commit 262f4a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/Internal/Marshaller/Type/DurationJsonType.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ public function parse($value, $current): CarbonInterval
{
if (\is_array($value) && isset($value['seconds']) && isset($value['nanos'])) {
// The highest precision is milliseconds either way.
$value = $value['seconds'] * 1_000_000_000 + $value['nanos'];
return DateInterval::parse($value, DateInterval::FORMAT_NANOSECONDS);
$value = $value['seconds'] * 1_000_000 + (int) \round($value['nanos'] / 1000);
return DateInterval::parse($value, DateInterval::FORMAT_MICROSECONDS);
}

if ($value === null) {
return CarbonInterval::create();
}

return DateInterval::parse($value, $this->fallbackFormat);
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Transport/Request/UpsertSearchAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class UpsertSearchAttributes extends Request
public function __construct(
private readonly array $searchAttributes,
) {
parent::__construct(self::NAME, ['searchAttributes' => $searchAttributes]);
parent::__construct(self::NAME, ['searchAttributes' => (object) $searchAttributes]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class UpsertTypedSearchAttributes extends Request
public function __construct(
private readonly array $searchAttributes,
) {
parent::__construct(self::NAME, ['search_attributes' => $this->prepareSearchAttributes()]);
parent::__construct(self::NAME, ['search_attributes' => (object) $this->prepareSearchAttributes()]);
}

/**
Expand Down

0 comments on commit 262f4a9

Please sign in to comment.