Uploading files to object storage fails #410

Open
opened 2026-01-30 09:02:57 +00:00 by ignaloidas · 2 comments
Contributor

As it says on the tin, whenever I'm trying to upload files it fails, with a
NetworkingError [ERR_INVALID_ARG_TYPE]: The options.agent property must be one of Agent-like Object, undefined, or false. Received an instance of Agent message in the logs.

I've worked around it by just removing setting the agent here

agent: getAgentByUrl(new URL(u), !meta.objectStorageUseProxy),

but something better should get done still.

I think the issue got introduced in 8c9667b2ca but I don't know JS/TS enough to understand what's wrong.

As it says on the tin, whenever I'm trying to upload files it fails, with a `NetworkingError [ERR_INVALID_ARG_TYPE]: The options.agent property must be one of Agent-like Object, undefined, or false. Received an instance of Agent` message in the logs. I've worked around it by just removing setting the agent here https://akkoma.dev/FoundKeyGang/FoundKey/src/commit/274265c94777f84f18faa83b03481fd2e8519d8c/packages/backend/src/services/drive/s3.ts#L21 but something better should get done still. I think the issue got introduced in 8c9667b2ca88d64f42b717b5ffcbb9a9e1e06ffd but I don't know JS/TS enough to understand what's wrong.
Owner

The error message seems a bit strange because it's asking for Agent and then complaining that it actually got Agent? Though since I don't have or use S3, I cannot test this.

As a further note, the aws-sdk package that Foundkey is using is no longer supported as of 2025-09-08 apparently. So even if this gets fixed, the currently used SDK might break at any time I guess.

I don't want to do that upgrade because as I said I don't use S3 and thus cannot test it. Also from a cursory look at the documentation (which I found very hard to understand) it seems that the agent configuration is not supported in the new version of the SDK, potentially requiring a large-ish rethink of the approach.

The error message seems a bit strange because it's asking for `Agent` and then complaining that it actually got `Agent`? Though since I don't have or use S3, I cannot test this. As a further note, the `aws-sdk` package that Foundkey is using is [no longer supported as of 2025-09-08](https://www.npmjs.com/package/aws-sdk) apparently. So even if this gets fixed, the currently used SDK might break at any time I guess. I don't want to do that upgrade because as I said I don't use S3 and thus cannot test it. Also from a cursory look at the documentation (which I found very hard to understand) it seems that the `agent` configuration is not supported in the new version of the SDK, potentially requiring a large-ish rethink of the approach.
Owner

The agent is used to:

  • set HTTP connection options
    • HTTP proxy
    • timeout
  • configure DNS resolution
    • prevent requests to private IP addresses

see also

const defaultAgentOptions = {
autoSelectFamily: true,
keepAliveTimeout: 30 * SECOND,
connect: {
lookup: cacheLookup,
},
};
/**
* non-proxy agent
*/
const _http = new Agent(defaultAgentOptions);
/**
* proxy agent (or non-proxy if no proxy is configured)
*/
export const httpAgent = config.proxy
? new ProxyAgent({
...defaultAgentOptions,
uri: config.proxy,
})
: _http;
/**
* Get agent by URL
* @param url URL
* @param bypassProxy Allways bypass proxy
*/
export function getAgentByUrl(url: URL, bypassProxy = false) {
if (bypassProxy || (config.proxyBypassHosts || []).includes(url.hostname)) {
return _http;
} else {
return httpAgent;
}
}

The agent is used to: * set HTTP connection options * HTTP proxy * timeout * configure DNS resolution * prevent requests to private IP addresses see also https://akkoma.dev/FoundKeyGang/FoundKey/src/commit/9ef8c421d9e41557a77bc4e134f35e09ba3bea76/packages/backend/src/misc/fetch.ts#L130-L164
Sign in to join this conversation.
No labels
feature
fix
upkeep
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
FoundKeyGang/FoundKey#410
No description provided.