{"record":{"id":"7ecf4c1257131026","repo":"goharbor/harbor","slug":"internal-dir-for-tls-not-exist","errorCode":null,"errorMessage":"Internal dir for tls {} not exist","messagePattern":"Internal dir for tls (.+?) not exist","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"make/photon/prepare/models.py","lineNumber":99,"sourceCode":"\n        # check certificate file\n        if filename.endswith('.crt'):\n            if not owner_can_read(path.stat().st_mode):\n                # check owner can read cert file\n                raise Exception('File {} should readable by owner'.format(filename))\n            if not san_existed(path):\n                # check SAN included\n                if filename == 'harbor_internal_ca.crt':\n                    return\n                raise Exception('cert file {} should include SAN'.format(filename))\n\n    def validate(self):\n        if not self.enabled:\n            # pass the validation if not enabled\n            return\n\n        if not internal_tls_dir.exists():\n            raise Exception('Internal dir for tls {} not exist'.format(internal_tls_dir))\n\n        for filename in self.required_filenames:\n            self._check(filename)\n\n    def prepare(self):\n        \"\"\"\n        Prepare moves certs in tls file to data volume with correct permission.\n        \"\"\"\n        if not self.enabled:\n            logging.info('internal tls NOT enabled...')\n            return\n        original_tls_dir = get_realpath(self.tls_dir)\n        if internal_tls_dir.exists():\n            rmtree(internal_tls_dir)\n        copytree(original_tls_dir, internal_tls_dir, symlinks=True)\n\n        for file in internal_tls_dir.iterdir():\n            if file.name.endswith('.key'):","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/make/photon/prepare/models.py#L81-L117","documentation":"ResolveData in src/pkg/scan/report/supported_mimes.go decodes raw report bytes into the model registered for the mime type in SupportedMimes. If the mime type IS supported but jsonData is zero-length it returns 'empty JSON data', because json.Unmarshal on empty input would only produce a less clear syntax error. Unsupported mime types deliberately return (nil, nil) and never reach this check.","triggerScenarios":"Calling ResolveData(mime, nil) or ResolveData(mime, []byte{}) with a mime present in SupportedMimes — e.g. after fetching a report whose body came back empty.","commonSituations":"A scanner adapter returned 200 with an empty body; a database column holding an empty report blob; passing the wrong variable for the data parameter.","solutions":["Length-check jsonData before calling ResolveData and treat empty data as an upstream fetch/storage failure","Fix the producer that stored or returned the empty report body","If a mime type is meant to bypass parsing, do not register it in SupportedMimes — unregistered mimes pass raw data through untouched"],"exampleFix":"// before\ndata, err := report.ResolveData(mime, body) // body may be empty\n\n// after\nif len(body) == 0 {\n    return nil, fmt.Errorf(\"report body for mime %s is empty\", mime)\n}\ndata, err := report.ResolveData(mime, body)","handlingStrategy":"validation","validationCode":"if len(jsonData) == 0 {\n    return nil, fmt.Errorf(\"no data to resolve for mime %s\", mime)\n}\nreturn report.ResolveData(mime, jsonData)","typeGuard":null,"tryCatchPattern":"data, err := report.ResolveData(mime, jsonData)\nif err != nil {\n    if strings.Contains(err.Error(), \"empty JSON data\") {\n        // data was fetched empty: fix the fetch, do not retry parse\n        return nil, fmt.Errorf(\"report body empty for %s\", mime)\n    }\n    return nil, err\n}","preventionTips":["Treat empty report bodies as fetch failures, not as parse inputs","Remember unsupported mimes return (nil, nil) by design — only registered mimes reach the parser","Store reports only after a successful non-empty read"],"tags":["go","harbor","json","scan","report","validation"],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}