refactor(tvix/castore): have SymlinkTarget-specific errors

Don't use ValidateNodeError, but SymlinkTargetError.

Also, add checks for too long symlink targets.

Change-Id: I4b533325d494232ff9d0b3f4f695f5a1a0a36199
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12230
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: edef <edef@edef.eu>
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2024-08-17 22:00:50 +03:00 committed by clbot
parent 56fa533e43
commit e086c76ee9
5 changed files with 172 additions and 26 deletions

View file

@ -3,7 +3,10 @@ use thiserror::Error;
use tokio::task::JoinError;
use tonic::Status;
use crate::path::{PathComponent, PathComponentError};
use crate::{
path::{PathComponent, PathComponentError},
SymlinkTargetError,
};
/// Errors related to communication with the store.
#[derive(Debug, Error, PartialEq)]
@ -22,8 +25,8 @@ pub enum ValidateNodeError {
#[error("invalid digest length: {0}")]
InvalidDigestLen(usize),
/// Invalid symlink target
#[error("Invalid symlink target: {}", .0.as_bstr())]
InvalidSymlinkTarget(bytes::Bytes),
#[error("Invalid symlink target: {0}")]
InvalidSymlinkTarget(SymlinkTargetError),
}
impl From<crate::digests::Error> for ValidateNodeError {