libnyanpasu/clash-nyanpasu · error · anyhow::Error
uid required for Profile editor
Error message
uid required for Profile editor
What it means
create_editor_window builds an EditorWindow for either the Profile editor or the CSS editor. The Profile variant embeds the profile uid in the window URL/params, so a None uid is invalid there and the function raises this error before creating any window.
Solutions
- Pass Some(uid) with the profile's id when window_type is EditorWindowType::Profile
- Make the caller resolve the selected profile before invoking the editor
- If uid is genuinely absent, fall back to CssEditor or show a user-facing selection prompt instead
- Consider splitting the API into create_profile_editor(uid) to make the parameter required
Example fix
// before
create_editor_window(app, EditorWindowType::Profile, None).await?;
// after
let uid = profiles.current().ok_or_else(|| anyhow!("no profile selected"))?;
create_editor_window(app, EditorWindowType::Profile, Some(uid.as_str())).await?; Defensive patterns
Strategy: validation
Validate before calling
if window_type == EditorWindowType::Profile && uid.is_none() {
return Err(anyhow!("Profile editor requires a uid"));
} Type guard
fn uid_for(window_type: EditorWindowType, uid: Option<&str>) -> Result<&str> {
match window_type {
EditorWindowType::Profile => uid.ok_or_else(|| anyhow!("uid required for Profile editor")),
EditorWindowType::CssEditor => Ok(uid.unwrap_or("")),
}
} Try / catch
match create_editor_window(app, window_type, uid).await {
Err(e) if e.to_string().contains("uid required") => {
// prompt user to select a profile first
}
other => other?,
} Prevention
- Make uid a required parameter by splitting Profile into its own constructor
- Resolve the current profile id before opening the editor
- Keep EditorWindowType and its required args together in one struct
When it happens
Trigger: Calling create_editor_window(app_handle, EditorWindowType::Profile, None) — or passing a uid only for other editor types — instead of supplying Some("<profile-uid>").
Common situations: Callers generic over EditorWindowType defaulting uid to None; a UI action launched from a context that lost the selected profile id; refactors that made uid optional for all editor kinds.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- clean-schema output failed validation
- failed to get close button
- failed to get close button
- failed to get miniaturize button
- failed to get miniaturize button
AI-assisted analysis of libnyanpasu/clash-nyanpasu@f7dbce2997 (2026-09-08).
Data as JSON: /api/errors/2248bc1e12d85af7.
Report an issue: GitHub.
Appendix: source
Thrown at backend/tauri/src/utils/resolve.rs:734
x: x as i32,
y: y as i32,
});
let _ = win.show();
let _ = win.set_focus();
Ok(())
}
/// Create editor window with window_type and optional uid
#[tracing_attributes::instrument(skip(app_handle))]
pub fn create_editor_window(
app_handle: &AppHandle,
window_type: EditorWindowType,
uid: Option<&str>,
) -> Result<()> {
let window = match &window_type {
EditorWindowType::Profile => {
let uid = uid.ok_or_else(|| anyhow::anyhow!("uid required for Profile editor"))?;
EditorWindow::profile(uid)
}
EditorWindowType::CssEditor => EditorWindow::css_editor(),
};
let mut builder = WindowParamsBuilder::new().param("type", window_type.type_str());
if let Some(u) = uid {
builder = builder.param("uid", u);
}
window.create_with_params(app_handle, builder.build())?;
Ok(())
}
/// Close editor window by window_type and optional uid
#[allow(dead_code)]
pub fn close_editor_window(
app_handle: &AppHandle,
window_type: &EditorWindowType,
uid: Option<&str>,View on GitHub (pinned to f7dbce2997)