Repository navigation
Percent-encode resource ids in URL paths - #152
Merged
Merged
Conversation
Callum027
suggested changes
Oct 15, 2026
Resource ids are free-form strings server-side (anything that is not a UUID gets hashed into one), and real-world ids contain characters that are significant in a URL. Cinder reports storage pools as "<host>@<backend>#<pool>"; putting that id raw into the path turns everything from '#' on into a URL fragment, so resource show/update/ delete and metric-by-resource requests land on "<host>@<backend>" -- a different, usually nonexistent resource -- and fail with 404. The Ceilometer gnocchi publisher hits this on every polled volume.provider.pool.capacity.* sample that carries resource attributes: the initial creation works (the id travels in the batch body) but the attribute update never does. Add utils.encode_resource_id() (urllib.parse.quote with safe="", so that a '/' in an id is encoded as well) and apply it wherever a resource id is spliced into a path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fivetime
force-pushed
the
fix/encode-resource-id
branch
from
October 17, 2026 16:14
6aa06d8 to
0978ea8
Compare
Contributor
|
@fivetime, could you please rebase this branch on the latest? @tobias-urdin, could you please approve running the pipeline? |
…client into fix/encode-resource-id
testtools is not one of this repository's test dependencies, so the module failed to import in an environment installed from .[test]. The tests only use assertEqual and assertTrue; use unittest.TestCase like the other unit tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Merged the latest master into the branch. While doing it I noticed the new test imported |
tobias-urdin
approved these changes
Oct 26, 2026
Contributor
Merge Queue Status
This pull request spent 4 minutes 41 seconds in the queue, including 4 minutes 2 seconds running CI. Required conditions to merge
|
14 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Resource ids are free-form strings on the server side (non-UUID ids get hashed into a UUID), and real-world ids contain characters that are significant in a URL. Cinder reports storage pools as
<host>@<backend>#<pool>; the client splices that id raw into the path, so everything from#on becomes a URL fragment and the server sees/v1/resource/volume_provider_pool/<host>@<backend>— a different, usually nonexistent resource → 404.Observed with Ceilometer's gnocchi publisher on
volume.provider.pool.capacity.*samples: creation works (the id travels in the batch body), but every attribute update is rejected:Fix
Add
utils.encode_resource_id()(urllib.parse.quote(..., safe="")) and apply it wherever a resource id is spliced into a path:ResourceManager.get/history/update/deleteand theMetricManagerresource-scoped paths (get,create,delete,get_measures,add_measures,set_measures). UUID ids are unchanged; the server decodes percent-encoding, verified against Gnocchi 4.7:safe=""is there so that a/in an id is encoded as well (quote()leaves/alone by default);@and#are encoded either way.Tests
gnocchiclient/tests/unit/test_resource_id_encoding.pypins the encoding and the URLs produced by each affected method. Unit suite and flake8 (with the repo's ignore list) pass.Co-authored with Claude (Anthropic); reviewed and tested by a human.