RJ
RJ•2y ago

Id format change with 0.17

Here's some real data (but for PII scrubbing) along with the validator that the error is matching it against.
{
address: {
addressLine1: "XXXXXX",
city: "XXXXX",
postalCode: "XXXX",
stateCode: "XX",
},
brandPartnerId: "Y7i91RWgmqVPw87q1R5MCA",
cancelAfterDate: "2023-06-28",
customer: {
emailAddress: "XXXXX",
name: "XXX",
phoneNumber: "XXX",
},
estimatedDeliveryDate: "2023-07-05",
orderDate: "2023-06-27",
purchaseOrderDate: "2023-06-27",
purchaseOrderNumber: "XXXXX",
retailer: "XXXXX",
tag: "Dropship",
}
{
address: {
addressLine1: "XXXXXX",
city: "XXXXX",
postalCode: "XXXX",
stateCode: "XX",
},
brandPartnerId: "Y7i91RWgmqVPw87q1R5MCA",
cancelAfterDate: "2023-06-28",
customer: {
emailAddress: "XXXXX",
name: "XXX",
phoneNumber: "XXX",
},
estimatedDeliveryDate: "2023-07-05",
orderDate: "2023-06-27",
purchaseOrderDate: "2023-06-27",
purchaseOrderNumber: "XXXXX",
retailer: "XXXXX",
tag: "Dropship",
}
v.union(
v.object({
address: v.object({
addressLine1: v.string(),
addressLine2: v.optional(v.string()),
city: v.string(),
postalCode: v.string(),
stateCode: v.string(),
}),
brandPartnerId: v.id("brandPartners"),
cancelAfterDate: v.string(),
customer: v.object({
emailAddress: v.string(),
name: v.string(),
phoneNumber: v.string(),
}),
estimatedDeliveryDate: v.string(),
orderDate: v.string(),
purchaseOrderDate: v.string(),
purchaseOrderNumber: v.string(),
retailer: v.union(
v.literal("Target"),
v.literal("Lowe's"),
v.literal("Home Depot"),
v.literal("Macy's"),
v.literal("Kohl's")
),
tag: v.literal("Dropship"),
}),
v.object({
brandPartnerId: v.id("brandPartners"),
cancelAfterDate: v.string(),
estimatedDeliveryDate: v.string(),
orderDate: v.string(),
purchaseOrderDate: v.string(),
purchaseOrderNumber: v.string(),
retailer: v.union(
v.literal("Target"),
v.literal("Lowe's"),
v.literal("Home Depot"),
v.literal("Macy's"),
v.literal("Kohl's")
),
tag: v.literal("B2B"),
})
v.union(
v.object({
address: v.object({
addressLine1: v.string(),
addressLine2: v.optional(v.string()),
city: v.string(),
postalCode: v.string(),
stateCode: v.string(),
}),
brandPartnerId: v.id("brandPartners"),
cancelAfterDate: v.string(),
customer: v.object({
emailAddress: v.string(),
name: v.string(),
phoneNumber: v.string(),
}),
estimatedDeliveryDate: v.string(),
orderDate: v.string(),
purchaseOrderDate: v.string(),
purchaseOrderNumber: v.string(),
retailer: v.union(
v.literal("Target"),
v.literal("Lowe's"),
v.literal("Home Depot"),
v.literal("Macy's"),
v.literal("Kohl's")
),
tag: v.literal("Dropship"),
}),
v.object({
brandPartnerId: v.id("brandPartners"),
cancelAfterDate: v.string(),
estimatedDeliveryDate: v.string(),
orderDate: v.string(),
purchaseOrderDate: v.string(),
purchaseOrderNumber: v.string(),
retailer: v.union(
v.literal("Target"),
v.literal("Lowe's"),
v.literal("Home Depot"),
v.literal("Macy's"),
v.literal("Kohl's")
),
tag: v.literal("B2B"),
})
It looks like it should match to me. Is this related to https://discord.com/channels/1019350475847499849/1122957485372887201 ?
8 Replies
ballingt
ballingt•2y ago
What's the validation error you get with this @RJ ?
RJ
RJOP•2y ago
In the logs from the Convex dashboard: Uncaught Error: Failed to insert or update a document in table "orders" because it does not match the schema: Value does not match validator. Followed by that value and that validator (that's one example)
lee
lee•2y ago
how are you getting the brandPartnerId? i believe valid ids are all lowercase
RJ
RJOP•2y ago
Uhhh it was hard-coded 😳 (I know, shame on me) I guess ID encodings changed with 0.17?
lee
lee•2y ago
yep they are now base32 instead of base64, and encode the table within the id. you can use db.normalizeId("brandPartners", "<hardcoded>") to get the new id
RJ
RJOP•2y ago
Got it, entirely my mistake then. I'll update my code and see if that fixes it. Thank you @lee!
sshader
sshader•2y ago
(The error message here was pretty uninformative, so we'll see if we can make it better)
RJ
RJOP•2y ago
Confirmed, that was the problem and it's now fixed

Did you find this page helpful?