Skip to content

Conversation

@hellosunghyun
Copy link

Summary

This PR adds a configurable max_request_line_size option to handle 414 (URI Too Long) errors that occur with very long continuation tokens in API requests.

Problem

Users are experiencing 414 errors when accessing channel videos with long continuation tokens. The default HTTP request line size limit (8KB) is insufficient for some YouTube continuation tokens, which can be extremely long.

Example error:

414 Client Error: URI Too Long for url: http://localhost:8080/api/v1/channels/UChQ-VMvdGrYZxviQVMTJOHg/videos?sort_by=newest&continuation=4qmFsgLT...

Solution

  • Added max_request_line_size configuration option to the Config class
  • Modified server initialization to apply the custom limit if configured
  • Provided clear documentation and examples for both config.yml and environment variable usage

Configuration

Users can now configure the limit in three ways:

  1. In config.yml:
max_request_line_size: 16384  # 16KB
  1. Via environment variable:
INVIDIOUS_MAX_REQUEST_LINE_SIZE=16384
  1. In docker-compose.yml:
environment:
  INVIDIOUS_MAX_REQUEST_LINE_SIZE: 16384

Default Behavior

  • The default behavior remains unchanged (8KB limit)
  • Only users experiencing 414 errors need to configure this option
  • Conservative default ensures security for public instances

Testing

  • Tested with long continuation tokens that previously caused 414 errors
  • Verified that the configuration is properly applied from all sources (config.yml, env var)
  • Confirmed that default behavior is maintained when option is not set

Security Considerations

  • Added documentation warning about increasing this value on public instances
  • The option is intentionally not enabled by default to maintain security posture

This change provides a flexible solution for users experiencing URL length issues without affecting existing installations.

Fixes issues related to long continuation tokens in channel video pagination.

This commit adds a new configuration option `max_request_line_size` that allows
users to increase the HTTP request line size limit. This is particularly useful
for handling very long continuation tokens that can cause 414 (URI Too Long) errors.

Changes:
- Add `max_request_line_size` property to Config class
- Configure Kemal server to use the custom limit if specified
- Document the option in config.example.yml with recommendations
- Add examples in docker-compose.yml for both YAML and env var configuration

The default behavior remains unchanged (8KB limit) unless explicitly configured.
This provides a solution for users experiencing 414 errors without affecting
existing installations.
Comment on lines +201 to +207
##
## Accepted values: integer (size in bytes)
## Default: 8192 (8KB, Crystal's default)
## Recommended: 16384 (16KB) if experiencing 414 errors
##
#max_request_line_size: 16384

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value should reflect the actual default value of 8192

##
## Accepted values: integer (size in bytes)
## Default: 8192 (8KB, Crystal's default)
## Recommended: 16384 (16KB) if experiencing 414 errors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any default recommendations is needed here. Imo instances should decide this value according to their own requirements and needs if they decide to stray from the default 8 kilobytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants