alibaba/open-code-review · error
resolver does not support detail inspection
Error message
resolver does not support detail inspection
What it means
After loading, runRulesCheck asserts the resolver implements the rules.DetailResolver interface needed to report which rule matched a path and why. If the concrete resolver lacks detail inspection, this error is thrown. It indicates a build/config combination where the resolver implementation cannot answer the `rules check` query.
Source
Thrown at cmd/opencodereview/rules_cmd.go:58
addRepoFlag(rulesCheckCmd, &rulesCheckRepoDir)
rulesCheckCmd.Flags().StringVar(&rulesCheckRulePath, "rule", "", "path to a custom rule JSON file")
rulesCmd.AddCommand(rulesCheckCmd)
}
func runRulesCheck(filePath string) error {
resolvedRepo, err := resolveRepoDir(rulesCheckRepoDir)
if err != nil {
return err
}
resolver, _, err := rules.NewResolver(resolvedRepo, rulesCheckRulePath, rules.ResolverOptions{})
if err != nil {
return fmt.Errorf("load rules: %w", err)
}
dr, ok := resolver.(rules.DetailResolver)
if !ok {
return fmt.Errorf("resolver does not support detail inspection")
}
detail := dr.ResolveDetail(filePath)
sourceLabel := map[string]string{
"custom": "Custom (--rule)",
"project": "Project (.opencodereview/rule.json)",
"global": "Global (~/.opencodereview/rule.json)",
"system": "System built-in",
}
fmt.Printf("File: %s\n", filePath)
fmt.Printf("Source: %s\n", sourceLabel[detail.Source])
fmt.Printf("Pattern: %s\n", detail.Pattern)
if detail.SniffedAs != "" {
fmt.Printf("Note: rule selected by file content (%s), not by path alone\n", detail.SniffedAs)
}
fmt.Println("Rule:")View on GitHub (pinned to 5cf97d0d15)
Solutions
- Rebuild the CLI from a clean checkout (`make build`) so resolver and command versions match.
- Upgrade to a release where the default resolver implements DetailResolver.
- If embedding the rules package, make your resolver implement the DetailResolver interface (ResolveDetail method).
Example fix
// before
type myResolver struct{} // no ResolveDetail
// after
type myResolver struct{}
func (r *myResolver) ResolveDetail(path string) rules.Detail { /* ... */ } Defensive patterns
Strategy: type-guard
Validate before calling
resolver, _, err := rules.NewResolver(repo, rulePath, rules.ResolverOptions{})
if err != nil { return err }
if _, ok := resolver.(rules.DetailResolver); !ok {
return errors.New("this build's resolver cannot show rule details; upgrade ocr")
} Type guard
dr, ok := resolver.(rules.DetailResolver)
if !ok {
return fmt.Errorf("resolver does not support detail inspection")
}
// dr is now narrowed to rules.DetailResolver Try / catch
if err := runRulesCheck(path); err != nil {
if strings.Contains(err.Error(), "detail inspection") {
// fall back to plain rule resolution without detail output
}
return err
} Prevention
- Rebuild from a clean checkout after pulling changes.
- Keep custom resolver implementations in sync with the rules package API.
- Pin a release version of ocr rather than mixing build artifacts.
When it happens
Trigger: `ocr rules check` when rules.NewResolver returns a resolver type that does not implement DetailResolver — e.g. an older/alternative resolver built by a mismatched build or stubbed GitRunner/test configuration.
Common situations: Mixed-version binary after an incomplete build; a custom resolver registered by configuration or code that predates the DetailResolver interface.
Related errors
- load rules: %w
- load rules: %w
- expected '{' in path_rule_map: %w
- expected '{' in path_rule_map, got %v
- read path_rule_map key: %w
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/1cf93f8912c6a311.
Report an issue: GitHub.