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
I have a bug when using dockerode's importImage function when passing the changes parameter (see apocas/dockerode#785). I found out that the serialization of query strings isn't standard for every parameter.
I found a fix by modifying the Modem.prototype.buildQuerystring function like so :
Modem.prototype.buildQuerystring=function(opts){varclone={};// serialize map and array values as JSON strings, else querystring truncates.// 't' and 'extrahosts' can be arrays but need special treatment so that they're// passed as multiple qs parameters instead of JSON values.console.log(`[DEBUG] <Modem.prototype.buildQuerystring> opts :`,opts);Object.keys(opts).map((key,i)=>{if(opts[key]&&typeofopts[key]==='object'&&!Array.isArray(opts[key])&&!['t','extrahosts'].includes(key)){clone[key]=JSON.stringify(opts[key]);}elseif(Array.isArray(opts[key])){clone[key]=opts[key].map((val)=>{if(val&&typeofval==='object'){returnJSON.stringify(val);}else{returnval;}});}else{clone[key]=opts[key];}});constqueryStr=querystring.stringify(clone);returnqueryStr;};
It seems that this is related to #144, so I will try to make the same change.
By not using the JSON syntax for values in the query string, the rest of the dockerode functions I use seem to work fine. I wonder if we should generalize the behaviour of the Modem.prototype.buildQuerystring function for arrays.
The text was updated successfully, but these errors were encountered:
Be removing the else if (Array.isArray(opts[key])) section, the fix still work as expected.
Extensive testing might be needed to ensure there are no breaking changes.
Clovel
changed the title
changes array parameter for /create/image is'nt serialized correctly changes array parameter for /create/image isn't serialized correctly
Jan 8, 2025
I have a bug when using
dockerode
'simportImage
function when passing thechanges
parameter (see apocas/dockerode#785). I found out that the serialization of query strings isn't standard for every parameter.I found a fix by modifying the
Modem.prototype.buildQuerystring
function like so :It seems that this is related to #144, so I will try to make the same change.
By not using the JSON syntax for values in the query string, the rest of the
dockerode
functions I use seem to work fine. I wonder if we should generalize the behaviour of theModem.prototype.buildQuerystring
function for arrays.The text was updated successfully, but these errors were encountered: