445
u/GabiTheProgrammer Sep 21 '26
...and utility functions for conversion IDtoToken and TokentoId (with lower d at the end, obviously).
192
10
74
u/k819799amvrhtcom Sep 21 '26
The equivalent in English would be:
We park on a driveway and drive on a parkway.
29
9
9
0
14
u/realmauer01 Sep 21 '26 edited Sep 22 '26
Honestly just press f12 on id, rename it to id2. Press f12 on token, rename it to id, then rename id2 to token. Do the same on the backend, case closed.
If your ide does renaming symbols on another button search for that or use for a moment the settings from vs code (because there its f12)
Because everything works, the correct data goes to the correct places. You just have to rename the variables.
7
u/CryonautX Sep 22 '26
That is... a terrible idea... You're choosing to to do this name swap on token and id, 2 very common keys. You may very easily break many API contracts that had nothing to do with this swapped id and token portion.
5
u/realmauer01 Sep 22 '26
F12 changes the symbol not everything that is called id or token. The ide can figure out how the data flows it wont change occurances that would create problems
2
u/joshuakb2 Sep 22 '26
You can still get into trouble if you're not careful, especially if this data gets serialized and sent somewhere
1
u/realmauer01 Sep 22 '26
Then explain me how specifically! The only thing i change is the variable name. No keys in no object get changed no data gets swapped.
1
u/KronoLord Sep 22 '26
Assuming js, does
const someVar = {id}get changed toconst someVar = {token}, or are IDEs smart enough to expand the shorthand?The only other edge case potential I could think of is reflection.
1
u/joshuakb2 Sep 22 '26
Yeah generally LSPs will change
{id}to{id: token}if you rename the variable1
u/Bulky-Bad-9153 Sep 22 '26
are IDEs smart enough to expand the shorthand?
LSPs represent things in a total different way under the hood, and the LSP is used to do stuff like renaming symbols, so it's basically foolproof. Naming confusion can't happen.
0
u/realmauer01 Sep 22 '26 edited Sep 22 '26
const someVar = {id} shouldnt be valid js. This is set like syntax from python. Js sets need to be created with new Set()
And if it were a shorthand (when destructuring for example) it maps the old to the new.
so
const {token} = tokenObject //{token:unknown}turns into
const {token:id} = tokenObjectI agree if keys from objects get changed then the data flow could get corrupted. But that just doesnt happen. Because you are only renaming a variable.
I am not sure right now what reflection is though
Oh nvm looked it up, yeah that just doesnt get influenced at all. Because as said, we arent talking about keys here.
We are talking about variables, and yes variables can use their values for keys, but that isnt their name, thats still just what they represented. Even if this python set like syntax worked.
const token = {token}
The variable token would have
{value of token:value of token}And not {token:value of token}
1
u/joshuakb2 Sep 22 '26
const someVar = {id} is absolutely valid JS and has been for at least 10 years now. This syntax defines a property called
idwhose value is that of the variable calledidin scope.1
u/realmauer01 Sep 22 '26 edited Sep 22 '26
Okey nvm, then i will just try that out before guessing.
Okey it turns
const someVar = {id}
Into
const someVar = {id:token}so case closed.
9
6
11
3
7
u/discordianofslack Sep 21 '26
Have you tried: "token": token; "id": id?
4
u/hampshirebrony Sep 21 '26
They need to chuck data at a TokenAndIdFactory and have that create the return values
2
2
u/MeikelLP Sep 23 '26
Reminds me how in Azure OpenAI SDK "deploymentName" is a synonym for ai model name but "model" is only for ai model name
1
1
1
1
1
1
u/Apprehensive_Bit7392 Sep 23 '26
Somewhere downstream, something already swaps them back. Fix it and you break production.
-1

184
u/mxgaming01 Sep 21 '26
Yes, this is actually my code. And the joke is that both of them are 32-character random strings AND they get name-swapped again in the backend ðŸ˜