diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php
index 212ddde..d5f8372 100644
--- a/tests/phpunit/tests/rest-api/rest-posts-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php
@@ -4549,6 +4549,68 @@ Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket baco
 		$this->assertSame( 'post-my-invalid-template.php', $data['template'] );
 	}
 
+	/**
+	 * Tests that a `rest_pre_insert_post` filter returning an object without an
+	 * `ID` property does not cause the update to fail.
+	 *
+	 * The filter is documented as receiving and returning a `stdClass`, so a
+	 * filter may build and return its own object rather than modifying the one it
+	 * was given. When that object has no `ID`, the cast to an array in
+	 * `update_item()` produces an array with no `ID` key, `wp_update_post()` then
+	 * calls `get_post( null )`, and the request fails with a 400 `invalid_post`
+	 * error instead of updating the post.
+	 *
+	 * @ticket 64921
+	 *
+	 * @covers WP_REST_Posts_Controller::update_item
+	 */
+	public function test_update_item_with_filtered_post_object_missing_id() {
+		wp_set_current_user( self::$editor_id );
+
+		add_filter( 'rest_pre_insert_post', array( $this, 'filter_rest_pre_insert_post_strip_identifiers' ) );
+
+		$request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
+		$request->set_body_params( array( 'title' => 'Updated through a filtered object' ) );
+
+		$response = rest_get_server()->dispatch( $request );
+
+		$this->assertSame( 200, $response->get_status(), 'The update should not fail when the filtered object omits ID.' );
+
+		$data = $response->get_data();
+		$this->assertSame( self::$post_id, $data['id'], 'The response should refer to the post from the request.' );
+		$this->assertSame(
+			'Updated through a filtered object',
+			get_post( self::$post_id )->post_title,
+			'The filtered title should have been saved to the post from the request.'
+		);
+	}
+
+	/**
+	 * Filter callback that returns a new object without the `ID` and
+	 * `post_parent` properties.
+	 *
+	 * This mirrors a filter that rebuilds the prepared post rather than
+	 * modifying the object it was given.
+	 *
+	 * @ticket 64921
+	 *
+	 * @param stdClass $prepared_post The prepared post object.
+	 * @return stdClass A new object with the identifier properties removed.
+	 */
+	public function filter_rest_pre_insert_post_strip_identifiers( $prepared_post ) {
+		$filtered = new stdClass();
+
+		foreach ( get_object_vars( $prepared_post ) as $property => $value ) {
+			if ( 'ID' === $property || 'post_parent' === $property ) {
+				continue;
+			}
+
+			$filtered->$property = $value;
+		}
+
+		return $filtered;
+	}
+
 	public function verify_post_roundtrip( $input = array(), $expected_output = array() ) {
 		// Create the post.
 		$request = new WP_REST_Request( 'POST', '/wp/v2/posts' );
