sakethsomaraju opened a new issue, #68065:
URL: https://github.com/apache/airflow/issues/68065
### Under which category would you file this issue?
Providers
### Apache Airflow version
2.1.12
### What happened and how to reproduce it?
When a variable key contains a leading slash (e.g. /test-var), the REST API
PATCH /api/v1/variables/{variable_key} endpoint cannot be reached successfully.
The leading slash in the key becomes part of the URL path, which causes routing
issues at the HTTP layer regardless of how the key is encoded:
Passing it unencoded (/variables//test-var) creates a double-slash that most
reverse proxies normalize or reject
Passing it percent-encoded (/variables/%2Fadt-batch-size) triggers a 308
redirect that strips the encoding, resolving back to /variables/test-var, a
different key, and the PATCH lands on the wrong resource or returns 400
Double-encoding (%252F) reaches the upstream but Airflow doesn't decode it
correctly, resulting in a 404
Airflow itself allows variable keys with leading slashes to be created (via
the UI or POST /variables), but there is no way to subsequently GET, PATCH, or
DELETE them via the REST API.
**Steps to reproduce**
Create a variable with a leading slash key via the Airflow UI or POST
/api/v1/variables:
jsonPOST /api/v1/variables
{ "key": "/test-var", "value": "test" }
Confirm it was created:
GET /api/v1/variables → 200, shows /test-var in the list
Attempt to update it via PATCH:
PATCH /api/v1/variables/%2Ftest-var → 308 redirect to
/api/v1/variables/test-var
PATCH /api/v1/variables//test-var → routing issue, wrong resource
PATCH /api/v1/variables/%252Ftest-var → 404, variable not found
All three approaches fail to update the intended variable.
### What you think should happen instead?
The PATCH /api/v1/variables/{variable_key} endpoint should be able to handle
variable keys that contain a leading slash. Since the key is a user-defined
string and Airflow already supports creation of such keys, the API should
support the full CRUD lifecycle for them. The recommended fix would be to
accept the variable key as a query parameter or request body field rather than
as a URL path segment, or to ensure percent-encoded path segments are preserved
end-to-end without redirect normalization.
### Operating System
linux
### Deployment
Astronomer
### Apache Airflow Provider(s)
_No response_
### Versions of Apache Airflow Providers
_No response_
### Official Helm Chart version
Not Applicable
### Kubernetes Version
_No response_
### Helm Chart configuration
_No response_
### Docker Image customizations
_No response_
### Anything else?
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]