allow redis family to be specified as a string #165

Manually merged
Johann150 merged 4 commits from redis-family-friendly-strings into main 2022-10-02 16:47:42 +00:00
Owner

This makes it consistent with outgoingAddressFamily, reducing
potential confusion.
outgoingAddressFamily removed per #165 (comment).

For compatibility reasons, numbers are still permitted for redis.family
with the following mapping:

  • dual = 0
  • ipv4 = 4
  • ipv6 = 6

Changelog: Changed

~~This makes it consistent with `outgoingAddressFamily`, reducing potential confusion.~~ `outgoingAddressFamily` removed per https://akkoma.dev/FoundKeyGang/FoundKey/pulls/165#issuecomment-3768. For compatibility reasons, numbers are still permitted for `redis.family` with the following mapping: - `dual` = `0` - `ipv4` = `4` - `ipv6` = `6` Changelog: Changed
norm force-pushed redis-family-friendly-strings from 9d1ee11d91 to c994562cce 2022-09-20 03:52:59 +00:00 Compare
Johann150 reviewed 2022-09-21 10:14:39 +00:00
@ -5,0 +7,4 @@
case 'ipv4': return 4;
case 'ipv6': return 6;
case 'dual': return 0;
default: return family ?? 0;
Owner

This does not protect against someone entering another string value, e.g. IPv4 will cause an error, as will IPv7. We should probably have a nicer error or warning message (default to dual?) instead of this verbose ioredis error:

[ioredis] Unhandled error event: TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.family' must be one of: 0, 4, 6. Received 'IPv7'
    at lookup (node:dns:183:11)
    at node:net:1186:5
    at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18)
    at lookupAndConnect (node:net:1185:3)
    at Socket.connect (node:net:1113:5)
    at Object.connect (node:net:234:17)
    at /home/misskey/misskey/node_modules/ioredis/built/connectors/StandaloneConnector.js:58:45
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
[ioredis] Unhandled error event: TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.family' must be one of: 0, 4, 6. Received 'IPv7'
    at lookup (node:dns:183:11)
    at node:net:1186:5
    at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18)
    at lookupAndConnect (node:net:1185:3)
    at Socket.connect (node:net:1113:5)
    at Object.connect (node:net:234:17)
    at /home/misskey/misskey/node_modules/ioredis/built/connectors/StandaloneConnector.js:58:45
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.family' must be one of: 0, 4, 6. Received 'IPv7'
    at lookup (node:dns:183:11)
    at node:net:1186:5
    at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18)
    at lookupAndConnect (node:net:1185:3)
    at Socket.connect (node:net:1113:5)
    at Object.connect (node:net:234:17)
    at /home/misskey/misskey/node_modules/ioredis/built/connectors/StandaloneConnector.js:58:45
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
  code: 'ERR_INVALID_ARG_VALUE'
}

Node.js v18.9.0
This does not protect against someone entering another string value, e.g. `IPv4` will cause an error, as will `IPv7`. We should probably have a nicer error or warning message (default to dual?) instead of this verbose ioredis error: ```text [ioredis] Unhandled error event: TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.family' must be one of: 0, 4, 6. Received 'IPv7' at lookup (node:dns:183:11) at node:net:1186:5 at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18) at lookupAndConnect (node:net:1185:3) at Socket.connect (node:net:1113:5) at Object.connect (node:net:234:17) at /home/misskey/misskey/node_modules/ioredis/built/connectors/StandaloneConnector.js:58:45 at process.processTicksAndRejections (node:internal/process/task_queues:77:11) [ioredis] Unhandled error event: TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.family' must be one of: 0, 4, 6. Received 'IPv7' at lookup (node:dns:183:11) at node:net:1186:5 at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18) at lookupAndConnect (node:net:1185:3) at Socket.connect (node:net:1113:5) at Object.connect (node:net:234:17) at /home/misskey/misskey/node_modules/ioredis/built/connectors/StandaloneConnector.js:58:45 at process.processTicksAndRejections (node:internal/process/task_queues:77:11) node:internal/process/promises:288 triggerUncaughtException(err, true /* fromPromise */); ^ TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.family' must be one of: 0, 4, 6. Received 'IPv7' at lookup (node:dns:183:11) at node:net:1186:5 at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18) at lookupAndConnect (node:net:1185:3) at Socket.connect (node:net:1113:5) at Object.connect (node:net:234:17) at /home/misskey/misskey/node_modules/ioredis/built/connectors/StandaloneConnector.js:58:45 at process.processTicksAndRejections (node:internal/process/task_queues:77:11) { code: 'ERR_INVALID_ARG_VALUE' } Node.js v18.9.0 ```
Contributor

Do we have any form of validation of the yaml config outside of the few asserts at start time? We could employ ajv here since it's already used in the project (assuming anyone other than me is a fan of it)

Do we have any form of validation of the yaml config outside of the few asserts at start time? We could employ ajv here since it's already used in the project (assuming anyone other than me is a fan of it)
Author
Owner

AFAIK there's not a whole lot of validation of the config, that error would have also happened with the current code in main as well.

AFAIK there's not a whole lot of validation of the config, that error would have also happened with the current code in main as well.
norm marked this conversation as resolved
norm force-pushed redis-family-friendly-strings from c550270d26 to b7d75feaff 2022-09-21 17:12:11 +00:00 Compare
Owner

On a sidenote, it seems that outgoingAddressFamily isn't actually used anywhere that I could find. So maybe instead of having the separate type declaration you could just remove that from the example config & config type since those seem to be the only places where it is present.

On a sidenote, it seems that `outgoingAddressFamily` isn't actually used anywhere that I could find. So maybe instead of having the separate type declaration you could just remove that from the example config & config type since those seem to be the only places where it is present.
norm force-pushed redis-family-friendly-strings from b7d75feaff to 8ca544c45d 2022-09-30 15:52:55 +00:00 Compare
Johann150 manually merged commit a7f9e244f3 into main 2022-10-02 16:47:42 +00:00
Johann150 deleted branch redis-family-friendly-strings 2022-10-02 16:48:02 +00:00
Sign in to join this conversation.
No reviewers
No labels
feature
fix
upkeep
No milestone
No project
No assignees
3 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#165
No description provided.