Compare commits

..

6 Commits

Author SHA1 Message Date
Kerollmops
ac428b5d7c Disallow todos from the Clippy CI 2025-12-15 13:36:47 +01:00
Kerollmops
1291990f7d Fix actix payload error handling 2025-12-15 13:36:46 +01:00
Clément Renault
2b6b4284bb Merge pull request #6000 from meilisearch/change-network-topology-2
Allow changing network topology
2025-12-15 11:09:56 +00:00
Louis Dureuil
018cad1781 add batch reason 2025-12-15 11:06:25 +01:00
Clément Renault
26e368b116 Merge pull request #6041 from meilisearch/fix-workflow-injection
Remove risk of command injection
2025-12-09 17:04:58 +00:00
curquiza
ba95ac0915 Remove risk of command injection 2025-12-09 17:06:41 +01:00
5 changed files with 56 additions and 11 deletions

View File

@@ -25,14 +25,18 @@ jobs:
- uses: actions/checkout@v5
- name: Define the Docker image we need to use
id: define-image
env:
EVENT_NAME: ${{ github.event_name }}
DOCKER_IMAGE_INPUT: ${{ github.event.inputs.docker_image }}
run: |
event=${{ github.event_name }}
echo "docker-image=nightly" >> $GITHUB_OUTPUT
if [[ $event == 'workflow_dispatch' ]]; then
echo "docker-image=${{ github.event.inputs.docker_image }}" >> $GITHUB_OUTPUT
if [[ "$EVENT_NAME" == 'workflow_dispatch' ]]; then
echo "docker-image=$DOCKER_IMAGE_INPUT" >> $GITHUB_OUTPUT
fi
- name: Docker image is ${{ steps.define-image.outputs.docker-image }}
run: echo "Docker image is ${{ steps.define-image.outputs.docker-image }}"
env:
DOCKER_IMAGE: ${{ steps.define-image.outputs.docker-image }}
run: echo "Docker image is $DOCKER_IMAGE"
##########
## SDKs ##

View File

@@ -196,7 +196,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets ${{ matrix.features }} -- --deny warnings
args: --all-targets ${{ matrix.features }} -- --deny warnings -D clippy::todo
fmt:
name: Run Rustfmt

View File

@@ -745,6 +745,7 @@ impl IndexScheduler {
mut current_batch: ProcessingBatch,
) -> Result<Option<(Batch, ProcessingBatch)>> {
current_batch.processing(Some(&mut task));
current_batch.reason(BatchStopReason::NetworkTask { id: task.uid });
let change_version =
task.network.as_ref().map(|network| network.network_version()).unwrap_or_default();
@@ -777,11 +778,16 @@ impl IndexScheduler {
task_version >= change_version
});
let (batch, current_batch) = res?;
let (batch, mut current_batch) = res?;
let batch = match batch {
Some(batch) => {
let inner_batch = Box::new(batch);
let inner_reason = current_batch.reason.to_string();
current_batch.reason(BatchStopReason::NetworkTaskOlderTasks {
id: task.uid,
inner_reason,
});
Batch::NetworkIndexBatch { network_task: task, inner_batch }
}
@@ -819,10 +825,15 @@ impl IndexScheduler {
task_version != change_version
});
let (batch, current_batch) = res?;
let (batch, mut current_batch) = res?;
let batch = batch.map(|batch| {
let inner_batch = Box::new(batch);
let inner_reason = current_batch.reason.to_string();
current_batch.reason(BatchStopReason::NetworkTaskImportTasks {
id: task.uid,
inner_reason,
});
(Batch::NetworkIndexBatch { network_task: task, inner_batch }, current_batch)
});

View File

@@ -899,6 +899,17 @@ pub enum BatchStopReason {
SettingsWithDocumentOperation {
id: TaskId,
},
NetworkTask {
id: TaskId,
},
NetworkTaskOlderTasks {
id: TaskId,
inner_reason: String,
},
NetworkTaskImportTasks {
id: TaskId,
inner_reason: String,
},
}
impl BatchStopReason {
@@ -987,6 +998,24 @@ impl Display for BatchStopReason {
"stopped before task with id {id} because it is a document operation which cannot be batched with settings changes"
)
}
BatchStopReason::NetworkTask { id } => {
write!(
f,
"stopped after task with id {id} because it is a network topology change task"
)
}
BatchStopReason::NetworkTaskOlderTasks { id, inner_reason } => {
write!(
f,
"stopped after batching network task with id {id} and a batch of older tasks: {inner_reason}"
)
}
BatchStopReason::NetworkTaskImportTasks { id, inner_reason } => {
write!(
f,
"stopped after batching network task with id {id} and a batch of import tasks: {inner_reason}"
)
}
}
}
}

View File

@@ -271,12 +271,13 @@ impl ErrorCode for PayloadError {
PayloadError::Payload(e) => match e {
ActixPayloadError::IncompleteError => Code::BadRequest,
ActixPayloadError::OtherError(error) => match error {
aweb::error::PayloadError::EncodingCorrupted => Code::Internal,
aweb::error::PayloadError::EncodingCorrupted => Code::BadRequest,
aweb::error::PayloadError::Overflow => Code::PayloadTooLarge,
aweb::error::PayloadError::UnknownLength => Code::Internal,
aweb::error::PayloadError::Http2Payload(_) => Code::Internal,
aweb::error::PayloadError::UnknownLength => Code::BadRequest,
aweb::error::PayloadError::Http2Payload(_) => Code::BadRequest,
aweb::error::PayloadError::Io(_) => Code::Internal,
_ => todo!(),
aweb::error::PayloadError::Incomplete(_) => Code::BadRequest,
_ => Code::Internal,
},
},
PayloadError::Json(err) => match err {