Verified Solution[gitlab-org/gitlab] [Bug] What is New Since - Custom URI throws 414 Request URI Too Long when sharing filtered views
Sponsored Content
### ROOT CAUSE
The issue arises because the custom URI generation for the "What is New Since" tool uses an excessive number of query parameters, exceeding the maximum URL length limit (typically around 2000-3000 characters). This occurs when sharing filtered views, as each filter adds multiple parameters, leading to a 414 Request URI Too Long error.
### CODE FIX
To resolve this, modify the URI generation to use a single base64-encoded JSON parameter instead of multiple query parameters. This reduces the URL length significantly while preserving all filter data.
1. **Frontend Change**:
- Collect all filter data (e.g., selected categories, date ranges).
- Convert the filter data into a JSON object.
- Base64-encode the JSON string.
- Append the encoded string as a single `filters` parameter to the URI.
```javascript
// Example: Build the URI
const filters = { categories: ['security', 'performance'], date: '2023-01-01' };
const filterData = JSON.stringify(filters);
const base64Filter = btoa(filterData); // btoa() is base64 encoding in JavaScript
const uri = `https://example.com/what-is-new-since?filters=${encodeURIComponent(base64Filter)}`;
```
2. **Backend Change**:
- Decode the base64 string to retrieve the filter data.
- Parse the JSON to apply the filters.
```python
# Example: Handle the URI in the backend (Python-like pseudocode)
import base64
import json
from flask import request
@app.route('/what-is-new-since')
def what_is_new_since():
filters_str = request.args.get('filters')
if filters_str:
decoded = base64.b64decode(filters_str).decode('utf-8')
filters_data = json.loads(decoded)
# Apply filters_data to the view
# ... rest of the code
```
This approach reduces the URL length by consolidating all filter data into one parameter, avoiding the 414 error while maintaining all filter functionality.
Deploy on DigitalOcean ($200 Credit)
Related Fixes
[StackOverflow/rust] Interfacing different Rust Po3 libraries
[StackOverflow/docker] Cannot get npm installed app to be present in final Docker image
[StackOverflow/rust] Why is there a difference regarding lifetime elision of impl trait function arguments between async and non-async functions?