{"record":{"id":"63642d6a0f4d4113","repo":"matryer/xbar","slug":"not-an-xbar-url","errorCode":null,"errorMessage":"not an xbar:// url","messagePattern":"not an xbar:// url","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/incoming_urls.go","lineNumber":25,"sourceCode":"\t\"github.com/pkg/errors\"\n)\n\ntype incomingURL struct {\n\t// Action is the action to take.\n\tAction string\n\t// Params are the parameters for the action.\n\tParams url.Values\n}\n\n// parseIncomingURL parses an incoming xbar:// URL.\nfunc parseIncomingURL(urlStr string) (incomingURL, error) {\n\tvar inURL incomingURL\n\tu, err := url.Parse(urlStr)\n\tif err != nil {\n\t\treturn inURL, err\n\t}\n\tif u.Scheme != \"xbar\" && u.Host != \"app.xbarapp.com\" {\n\t\treturn inURL, errors.New(\"not an xbar:// url\")\n\t}\n\tinURL.Action = strings.Trim(u.Path, \"/\")\n\tinURL.Params = u.Query()\n\tswitch inURL.Action {\n\tcase \"openPlugin\":\n\tcase \"refreshPlugin\":\n\tcase \"refreshAllPlugins\":\n\tdefault: // not ok\n\t\treturn inURL, errors.Errorf(\"unsupported action %q\", inURL.Action)\n\t}\n\treturn inURL, nil\n}\n","sourceCodeStart":7,"sourceCodeEnd":38,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/app/incoming_urls.go#L7-L38","documentation":"parseIncomingURL only accepts URLs whose scheme is 'xbar' (or whose host is 'app.xbarapp.com'). Any other input — https://, plain text, empty string, malformed URLs — fails this scheme/host check and is rejected so the app never dispatches an action from a foreign link. It is thrown early, before any action or params are extracted.","triggerScenarios":"Calling parseIncomingURL (directly or via handleIncomingURL) with a string that is not an xbar:// URL and not an app.xbarapp.com URL, e.g. \"https://xbarapp.com/openPlugin\", \"\", or \"foo://bar\". Note the check uses && so a URL like \"mailto:app.xbarapp.com\" (wrong scheme AND right host absent) also fails.","commonSituations":"Deep links pasted from a browser with the scheme mangled or URL-encoded; users clicking an https link instead of the xbar:// link from docs; tests passing arbitrary URLs; OS registering the xbar:// handler to a different app so a normalized https URL is forwarded.","solutions":["Ensure the URL string starts with the xbar:// scheme, e.g. xbar://openPlugin?path=...","If using an https deep link, make sure the host is exactly app.xbarapp.com and the path is /<action>","URL-decode the input if it arrived percent-encoded, then re-parse","Fix the OS/browser handler so xbar:// links reach the app unchanged instead of being rewritten to https"],"exampleFix":"// before\nparseIncomingURL(\"https://example.com/refreshAllPlugins\")\n// after\nparseIncomingURL(\"xbar://refreshAllPlugins\")","handlingStrategy":"validation","validationCode":"func isXbarURL(raw string) bool {\n\tu, err := url.Parse(raw)\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn u.Scheme == \"xbar\" || u.Host == \"app.xbarapp.com\"\n}","typeGuard":"func isXbarURL(u *url.URL) bool {\n\treturn u != nil && (u.Scheme == \"xbar\" || u.Host == \"app.xbarapp.com\")\n}","tryCatchPattern":"inURL, err := parseIncomingURL(raw)\nif err != nil {\n\tif err.Error() == \"not an xbar:// url\" {\n\t\t// reject or show a friendly 'unsupported link' message\n\t\treturn\n\t}\n\treturn err\n}","preventionTips":["Always construct deep links starting with xbar://","If linking from the web, use https://app.xbarapp.com/<action> exactly","URL-encode params but never the scheme","Add a unit test covering the exact error string"],"tags":["url","parsing","scheme-validation","go"],"backgroundTag":"invalid-url-scheme","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}