Repository navigation
Route browser fs and logs endpoints directly to the VM #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9088723
Route browser fs and logs endpoints directly to the VM
tnsardesai 9600600
Address review: narrow multipart change, prove rewinds, always evict
tnsardesai c01804d
Evict a stale direct-to-VM route before the error body is read
tnsardesai 41ebeda
Run the route eviction hook before caller response hooks
tnsardesai fe23cc7
Align routing tests with filesystem responses
tnsardesai bb70883
Merge branch 'main' into hypeship/direct-vm-fs-logs
tnsardesai 733f523
Prevent replaying streams after auth read errors
tnsardesai f33e9ca
Fix routing test stream types
tnsardesai 5d8ec7f
Preserve stream replayability before request hooks
tnsardesai 92acf13
Prevent retries of unreplayable VM bodies
tnsardesai 1a3bbc3
Harden direct VM request handling
tnsardesai 3037090
Evict the originating browser route cache
tnsardesai ba94ef3
Preserve direct request ownership
tnsardesai 94c0e23
Evict stale routes from browser streams
tnsardesai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import Mapping, Sequence, cast | ||
|
|
||
| from .._utils import is_given | ||
|
|
||
| __all__ = ["indexed_multipart_body"] | ||
|
|
||
|
|
||
| def indexed_multipart_body(body: object) -> dict[str, object]: | ||
| """Flatten a multipart body so that array entries carry their index. | ||
|
|
||
| Endpoints that take an array of objects with a file field need each entry's | ||
| fields grouped together: `files[0][dest_path]` pairs with the `files[0][file]` | ||
| part, while repeated `files[][dest_path]` names cannot be matched back to | ||
| their file. The returned mapping is already flat, so the client's generic | ||
| multipart serialization passes the names through untouched and every other | ||
| endpoint keeps its existing encoding. | ||
| """ | ||
| flattened: dict[str, object] = {} | ||
| if isinstance(body, Mapping): | ||
| for key, value in cast(Mapping[object, object], body).items(): | ||
| _flatten(str(key), value, flattened) | ||
| return flattened | ||
|
|
||
|
|
||
| def _flatten(key: str, value: object, out: dict[str, object]) -> None: | ||
| if not is_given(value): | ||
| return | ||
|
|
||
| if isinstance(value, Mapping): | ||
| for child_key, child in cast(Mapping[object, object], value).items(): | ||
| _flatten(f"{key}[{child_key}]", child, out) | ||
| return | ||
|
|
||
| if isinstance(value, (list, tuple)): | ||
| for index, child in enumerate(cast(Sequence[object], value)): | ||
| _flatten(f"{key}[{index}]", child, out) | ||
| return | ||
|
|
||
| out[key] = value |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.