Skip to content

Commit 7914169

Browse files
fix: handle string WikiType enum from ADO API in branch resolution (#122)
The ADO Wiki REST API returns the wiki type as a string enum ("codeWiki" / "projectWiki"), not a numeric value. The previous code used as_u64() which always returned None for strings, causing every wiki to be misidentified as a project wiki. This meant the versionDescriptor was never added to PUT requests on code wikis, triggering HTTP 400 errors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a057598 commit 7914169

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/tools/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,16 @@ pub(crate) async fn resolve_wiki_branch(
7070
}
7171
};
7272

73-
// type 0 = project wiki, type 1 = code wiki
74-
let wiki_type = body.get("type").and_then(|v| v.as_u64()).unwrap_or(0);
75-
if wiki_type != 1 {
76-
debug!("Wiki is a project wiki (type {wiki_type}) — no branch needed");
73+
// Detect code wikis. ADO returns the type as a string enum ("codeWiki" /
74+
// "projectWiki") rather than a numeric value, so we check both forms.
75+
let is_code_wiki = match body.get("type") {
76+
Some(serde_json::Value::String(s)) => s.eq_ignore_ascii_case("codewiki"),
77+
Some(serde_json::Value::Number(n)) => n.as_u64() == Some(1),
78+
_ => false,
79+
};
80+
if !is_code_wiki {
81+
let type_val = body.get("type").cloned().unwrap_or(serde_json::Value::Null);
82+
debug!("Wiki is a project wiki (type {type_val}) — no branch needed");
7783
return Ok(None);
7884
}
7985

0 commit comments

Comments
 (0)