Page MenuHomePhabricator

Getting HTTP 404 saving Wikicode if there is an edit conflict and a short amount of time has passed
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

Run this sample program:

use std::time::Duration;

use mwbot::parsoid::{Wikicode, WikinodeIterator};
use mwbot::{Bot, SaveOptions};
use tokio::time::sleep;

#[tokio::main(flavor = "current_thread")]
async fn main() {
    let bot = Bot::from_default_config().await.unwrap();
    let sandbox_title = "User:Count Count/sandbox";
    let sandbox_page = bot.page(sandbox_title).unwrap();
    let wikicode = sandbox_page.html().await.unwrap();
    let mut wikitext = sandbox_page.wikitext().await.unwrap();
    wikitext.push_str("\n* Test");
    bot.page(sandbox_title)
        .unwrap()
        .save(wikitext, &SaveOptions::summary("Creating an edit conflict"))
        .await
        .unwrap();
    let mutable_wikicode = wikicode.into_mutable();
    mutable_wikicode.append(&Wikicode::new_text("Other Test"));
    sleep(Duration::from_secs(2)).await;
    sandbox_page
        .save(mutable_wikicode, &SaveOptions::summary("Conflicting edit"))
        .await
        .unwrap();
}

What happens?:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: HttpError(reqwest::Error { kind: Status(404), url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("en.wikipedia.org")), port: None, path: "/api/rest_v1/transform/html/to/wikitext/User%3ACount%20Count%2Fsandbox/1147476512", query: None, fragment: None } })', src/main.rs:26:10
`

What should have happened instead?:

Getting an EditConflict error.

Software version (skip for WMF-hosted wikis like Wikipedia):

mwbot = "0.5.0-alpha.4"
tokio = { version = "1.26.0", features = [ "rt", "macros" ] }

Other information (browser name/version, screenshots, etc.):
1 sec is enough in my tests too.

I assume Parsoid removes the data associated with the render once a new version of a page is created and returns 404. I tested this without passing the ETag of the render in the if-match header but that does not work either. I wonder how the Visual Editor does this.