You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Type Error. ObjectSerializer expects a date but gets a string.
TypeError: data.toISOString is not a function
at ObjectSerializer.serialize (file:///Users/bensaxon/Documents/code/monorepo/src/private/console/node_modules/.pnpm/@[email protected]/node_modules/@kubernetes/client-node/dist/gen/models/ObjectSerializer.js:2024:29)
The code expects data to be a Date object with a toISOString method.
Instead, when I log the result, I actually get a string, already in ISO format, such as:
2025-01-30T09:58:20.000Z
This is because the resource that I pass into the client has a metadata.creationTimestamp field that is a string. I would rather not have to convert it into a Date. Since I receive it as a string from API requests. I like it as a string. I know it's "supposed" to be a Date according to the type, but it's just impractical. I think it's a bad developer experience. Also, this error does not occur in v0.
Client Version 1.0.0
To Reproduce
Steps to reproduce the behaviour:
The error is thrown when trying to make a PUT request.
Ensure that resource.metadata.creationTimestamp is a string, not a date object.
I expect the error not to throw. I suggest putting a conditional inside the serialize function that checks if data is of type string before assuming it's a Date object. If data is a string, then return it as is, else return data.toISOstring().
The text was updated successfully, but these errors were encountered:
We rely on code generation because the surface area of the Kubernetes API is too large to have hand-written code maintained by a small number of maintainers.
If you want to raise a PR on that repo to modify the generator so that it can handle both strings or Date objects, I bet they will accept it, but that's where the change needs to be made.
Describe the bug
Type Error. ObjectSerializer expects a date but gets a string.
The issue is happening here.
The code expects
data
to be aDate
object with atoISOString
method.Instead, when I log the result, I actually get a string, already in ISO format, such as:
2025-01-30T09:58:20.000Z
This is because the resource that I pass into the client has a
metadata.creationTimestamp
field that is a string. I would rather not have to convert it into a Date. Since I receive it as a string from API requests. I like it as a string. I know it's "supposed" to be a Date according to the type, but it's just impractical. I think it's a bad developer experience. Also, this error does not occur in v0.Client Version
1.0.0
To Reproduce
Steps to reproduce the behaviour:
The error is thrown when trying to make a PUT request.
Ensure that
resource.metadata.creationTimestamp
is a string, not a date object.Make a Patch request:
Expected behaviour
I expect the error not to throw. I suggest putting a conditional inside the serialize function that checks if
data
is of type string before assuming it's aDate
object. Ifdata
is a string, then return it as is, else returndata.toISOstring()
.The text was updated successfully, but these errors were encountered: