mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
path-uri: remove legacy path deserialization (#29158)
## Why I'd originally added `PathUri` legacy path deserialization thinking we'd want it for having `PathUri` in public app-server APIs. Since then we've added `LegacyAppPathString` to handle the messy conversions that we need for backcompat. It's confusing for `PathUri` to support deserializing legacy paths when we don't yet want to actually expose app-server callers or rollout storage to the new URI format. Stacked on top of #29472 to avoid breaking compatibility in case those types ended up stored somewhere for someone. ## What changed - Parse deserialized `PathUri` values exclusively as valid `file:` URIs. - Replace legacy acceptance coverage with rejection coverage for top-level filesystem paths and sandbox working directories. - Serialize CWDs in hand-built exec-server process requests as `PathUri` values.
This commit is contained in:
1 parent
5283522939
commit
c26f961b85
5 files changed
+41
-75
No files matched your search
@@ -45,13 +45,9 @@ const BAD_PATH_URI_PREFIX: &str = "file:///%00/bad/path/";
|
||||
/// are not resolved.
|
||||
///
|
||||
/// Serde represents a `PathUri` as its canonical URI string. Deserialization
|
||||
/// also accepts an absolute native path for compatibility with fields that
|
||||
/// previously used [`AbsolutePathBuf`]; relative paths are rejected. Valid
|
||||
/// `file:` strings round-trip through their canonical URL form, including
|
||||
/// encoded non-UTF-8 path bytes, but conversion to a native path remains
|
||||
/// host-dependent as described by [RFC 8089].
|
||||
/// accepts only valid `file:` URI strings. These strings round-trip through
|
||||
/// their canonical URL form, including encoded non-UTF-8 path bytes.
|
||||
///
|
||||
/// [RFC 8089]: https://www.rfc-editor.org/rfc/rfc8089.html
|
||||
/// [VS Code resources]: https://github.com/microsoft/vscode/blob/main/src/vs/base/common/resources.ts
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, TS)]
|
||||
#[ts(type = "string")]
|
||||
@@ -478,30 +474,7 @@ impl<'de> Deserialize<'de> for PathUri {
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let value = String::deserialize(deserializer)?;
|
||||
let unsupported_scheme = match Url::parse(&value) {
|
||||
Ok(url) => match Self::try_from(url) {
|
||||
Ok(uri) => return Ok(uri),
|
||||
// `Url` parses a Windows drive prefix such as `C:\` as the
|
||||
// scheme `c`. Give any unsupported URI one chance to satisfy
|
||||
// the native absolute-path invariant before reporting it.
|
||||
Err(error @ PathUriParseError::UnsupportedScheme(_)) => Some(error),
|
||||
Err(error) => return Err(serde::de::Error::custom(error)),
|
||||
},
|
||||
Err(url::ParseError::RelativeUrlWithoutBase) => None,
|
||||
Err(error) => {
|
||||
return Err(serde::de::Error::custom(PathUriParseError::InvalidUri(
|
||||
error,
|
||||
)));
|
||||
}
|
||||
};
|
||||
|
||||
let path = AbsolutePathBuf::from_absolute_path_checked(value).map_err(|path_error| {
|
||||
serde::de::Error::custom(
|
||||
unsupported_scheme
|
||||
.map_or_else(|| path_error.to_string(), |error| error.to_string()),
|
||||
)
|
||||
})?;
|
||||
Ok(Self::from_abs_path(&path))
|
||||
Self::parse(&value).map_err(serde::de::Error::custom)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user