{"record":{"id":"833da15ceafa596b","repo":"gohugoio/hugo","slug":"failed-to-create-resource-spec-w","errorCode":null,"errorMessage":"failed to create resource spec: %w","messagePattern":"failed to create resource spec: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/deps.go","lineNumber":272,"sourceCode":"\t}\n\n\tif d.SourceSpec == nil {\n\t\td.SourceSpec = source.NewSourceSpec(d.PathSpec, nil, d.Fs.Source)\n\t}\n\n\tvar common *resources.SpecCommon\n\tif d.ResourceSpec != nil {\n\t\tcommon = d.ResourceSpec.SpecCommon\n\t}\n\n\td.Cfg.BaseConfig()\n\n\tfileCaches := d.Cfg.FileCaches().(filecache.Caches)\n\tfileCaches.SetResourceFs(d.BaseFs.ResourcesCache)\n\n\tresourceSpec, err := resources.NewSpec(d.PathSpec, common, d.WasmDispatchers, fileCaches, d.MemCache, d.BuildState, d.Log, d, d.ExecHelper, d.BuildClosers, d.BuildState)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create resource spec: %w\", err)\n\t}\n\td.ResourceSpec = resourceSpec\n\n\treturn nil\n}\n\n// TODO(bep) rework this to get it in line with how we manage templates.\nfunc (d *Deps) Compile(prototype *Deps) error {\n\tvar err error\n\tif prototype == nil {\n\n\t\tif err = d.TranslationProvider.NewResource(d); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\n\tif err = d.TranslationProvider.CloneResource(d, prototype); err != nil {","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/deps/deps.go#L254-L290","documentation":"During Deps initialization (deps/deps.go:270) Hugo builds the resources.Spec via resources.NewSpec, which constructs the image processor (images.NewImageProcessor from the [imaging] config), the permalink expander (page.NewPermalinkExpander from [permalinks]), and caches. This wraps any of those failures, most commonly a bad imaging config.","triggerScenarios":"Invalid [imaging] config (bad quality, unsupported filter, unknown anchor, misconfigured resize options); invalid [permalinks] entries that page.NewPermalinkExpander cannot compile; nil/missing cache or logger wiring in a programmatic embed.","commonSituations":"Setting [imaging] quality out of range, an unsupported resampling filter name, or a bad anchor after a Hugo upgrade; a malformed permalink token; embedding Hugo programmatically with incomplete Deps.","solutions":["Inspect the wrapped %w error to see whether imaging or permalinks failed.","Validate [imaging]: quality 1-100, a supported resamplingFilter, a valid anchor.","Validate [permalinks]: tokens match ':field' form and field names are valid.","If embedding Hugo, ensure PathSpec, FileCaches, logger, MemCache and BuildState are populated before calling Deps.Init."],"exampleFix":"# before\n[imaging]\nquality = 150          # out of range -> resource spec fails\nresampleFilter = \"foo\"  # unknown filter\n\n# after\n[imaging]\nquality = 75\nresampleFilter = \"box\"","handlingStrategy":"validation","validationCode":"// Validate the config slices that feed resources.NewSpec.\nfunc ValidateResourceSpecConfig(imagingCfg images.Config, permalinks map[string]string) error {\n    // imaging: sanity-check quality/filter/anchor per Hugo docs.\n    if imagingCfg.Quality < 1 || imagingCfg.Quality > 100 {\n        return fmt.Errorf(\"imaging.quality must be 1-100\")\n    }\n    for kind, pattern := range permalinks {\n        if strings.ContainsAny(pattern, \" \") {\n            return fmt.Errorf(\"permalinks.%s: invalid pattern %q\", kind, pattern)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := d.Init(); err != nil { // calls resources.NewSpec internally\n    return fmt.Errorf(\"init deps: %w\", err)\n}","preventionTips":["Keep [imaging] quality in 1-100 and use a documented resampleFilter/anchor.","Validate [permalinks] tokens after Hugo upgrades.","When embedding Hugo, fully populate Deps (PathSpec, FileCaches, MemCache, BuildState, logger) before Init."],"tags":["resources","config","imaging"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}