mirror of
https://github.com/openai/codex.git
synced 2026-10-20 17:38:45 +00:00
Handle unsupported fs/writeBlock requests in exec-server (#49811)
## What changed Register `fs/writeBlock` and require filesystem initialization before handling it. Validate the file handle ID, then return an invalid-request error stating that writable file streams are unsupported. GitOrigin-RevId: 13440e497a88ca6505ee60d95bbb771d3cae06b8
This commit is contained in:
committed by
copyberry
parent
cca440697f
commit
c51f5bfb82
@@ -42,6 +42,8 @@ use crate::protocol::FsRemoveParams;
|
||||
use crate::protocol::FsRemoveResponse;
|
||||
use crate::protocol::FsWalkParams;
|
||||
use crate::protocol::FsWalkResponse;
|
||||
use crate::protocol::FsWriteBlockParams;
|
||||
use crate::protocol::FsWriteBlockResponse;
|
||||
use crate::protocol::FsWriteFileParams;
|
||||
use crate::protocol::FsWriteFileResponse;
|
||||
use crate::rpc::internal_error;
|
||||
@@ -158,6 +160,17 @@ impl FileSystemHandler {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) async fn write_block(
|
||||
&self,
|
||||
params: FsWriteBlockParams,
|
||||
) -> Result<FsWriteBlockResponse, JSONRPCErrorError> {
|
||||
validate_file_handle_id(¶ms.handle_id)?;
|
||||
// TODO(anp): Implement positional writes before advertising writable file streams.
|
||||
Err(invalid_request(
|
||||
"exec-server does not support writable file streams".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
pub(crate) async fn close(
|
||||
&self,
|
||||
params: FsCloseParams,
|
||||
@@ -371,6 +384,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::FileSystemSandboxContext;
|
||||
use crate::protocol::FsReadFileParams;
|
||||
|
||||
use crate::protocol::FsWriteFileParams;
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -50,6 +50,8 @@ use crate::protocol::FsRemoveParams;
|
||||
use crate::protocol::FsRemoveResponse;
|
||||
use crate::protocol::FsWalkParams;
|
||||
use crate::protocol::FsWalkResponse;
|
||||
use crate::protocol::FsWriteBlockParams;
|
||||
use crate::protocol::FsWriteBlockResponse;
|
||||
use crate::protocol::FsWriteFileParams;
|
||||
use crate::protocol::FsWriteFileResponse;
|
||||
use crate::protocol::HTTP_REQUEST_METHOD;
|
||||
@@ -340,6 +342,14 @@ impl ExecServerHandler {
|
||||
self.file_system.read_block(params).await
|
||||
}
|
||||
|
||||
pub(crate) async fn fs_write_block(
|
||||
&self,
|
||||
params: FsWriteBlockParams,
|
||||
) -> Result<FsWriteBlockResponse, JSONRPCErrorError> {
|
||||
self.require_initialized_for("filesystem")?;
|
||||
self.file_system.write_block(params).await
|
||||
}
|
||||
|
||||
pub(crate) async fn fs_close(
|
||||
&self,
|
||||
params: FsCloseParams,
|
||||
|
||||
@@ -26,9 +26,11 @@ use crate::protocol::FS_READ_DIRECTORY_METHOD;
|
||||
use crate::protocol::FS_READ_FILE_METHOD;
|
||||
use crate::protocol::FS_REMOVE_METHOD;
|
||||
use crate::protocol::FS_WALK_METHOD;
|
||||
use crate::protocol::FS_WRITE_BLOCK_METHOD;
|
||||
use crate::protocol::FS_WRITE_FILE_METHOD;
|
||||
use crate::protocol::FsCloseParams;
|
||||
use crate::protocol::FsReadBlockParams;
|
||||
use crate::protocol::FsWriteBlockParams;
|
||||
use crate::protocol::HTTP_REQUEST_METHOD;
|
||||
use crate::protocol::HttpRequestParams;
|
||||
use crate::protocol::INITIALIZE_METHOD;
|
||||
@@ -151,6 +153,12 @@ pub(crate) fn build_router() -> RpcRouter<ExecServerHandler> {
|
||||
handler.fs_read_block(params).await
|
||||
},
|
||||
);
|
||||
router.request(
|
||||
FS_WRITE_BLOCK_METHOD,
|
||||
|handler: Arc<ExecServerHandler>, params: FsWriteBlockParams| async move {
|
||||
handler.fs_write_block(params).await
|
||||
},
|
||||
);
|
||||
router.request(
|
||||
FS_CLOSE_METHOD,
|
||||
|handler: Arc<ExecServerHandler>, params: FsCloseParams| async move {
|
||||
|
||||
Reference in New Issue
Block a user