HelloZeroNet/ZeroNet · error

Invalid content.json file: %s

Error message

Invalid content.json file: %s

What it means

actionSiteSign needs to locate the content.json that governs the file being signed. When inner_path is not itself a content.json, it asks content_manager.getFileInfo(inner_path); if that returns None the file does not belong to any known content.json rule, so signing is impossible and this Exception is raised.

Source

Thrown at src/Ui/UiWebsocket.py:415

                for key, val in stats.items():
                    if key.startswith("num_"):
                        back[tracker][key] = back[tracker].get(key, 0) + val
                    elif is_latest_data:
                        back[tracker][key] = val

        return back

    # Sign content.json
    def actionSiteSign(self, to, privatekey=None, inner_path="content.json", remove_missing_optional=False, update_changed_files=False, response_ok=True):
        self.log.debug("Signing: %s" % inner_path)
        site = self.site
        extend = {}  # Extended info for signing

        # Change to the file's content.json
        file_info = site.content_manager.getFileInfo(inner_path)
        if not inner_path.endswith("content.json"):
            if not file_info:
                raise Exception("Invalid content.json file: %s" % inner_path)
            inner_path = file_info["content_inner_path"]

        # Add certificate to user files
        is_user_content = file_info and ("cert_signers" in file_info or "cert_signers_pattern" in file_info)
        if is_user_content and privatekey is None:
            cert = self.user.getCert(self.site.address)
            extend["cert_auth_type"] = cert["auth_type"]
            extend["cert_user_id"] = self.user.getCertUserId(site.address)
            extend["cert_sign"] = cert["cert_sign"]
            self.log.debug("Extending content.json with cert %s" % extend["cert_user_id"])

        if not self.hasFilePermission(inner_path):
            self.log.error("SiteSign error: you don't own this site & site owner doesn't allow you to do so.")
            return self.response(to, {"error": "Forbidden, you can only modify your own sites"})

        if privatekey == "stored":  # Get privatekey from sites.json
            privatekey = self.user.getSiteData(self.site.address).get("privatekey")
            if not privatekey:

View on GitHub (pinned to 454c0b2e7e)

Solutions

  1. Verify the file path exists on disk and is covered by an include pattern (e.g. 'files/**') in the site's content.json
  2. Call content_manager.getFileInfo(inner_path) yourself first to confirm the file is tracked before signing
  3. Update content.json include patterns to cover the file, re-sign the content.json, then sign the file
  4. Check inner_path spelling, leading slash, and that you're passing a relative inner path (no site address prefix)

Example fix

// before
site_info = ws.api.siteSign(inner_path='data/newfile.json')
// after
if not ws.api.siteInfo()['content_manager'].getFileInfo('data/newfile.json'):
    raise ValueError('add data/newfile.json to content.json include patterns first')
site_info = ws.api.siteSign(inner_path='data/newfile.json')
Defensive patterns

Strategy: validation

Validate before calling

file_info = site.content_manager.getFileInfo(inner_path)
if not inner_path.endswith('content.json') and not file_info:
    raise ValueError(f'{inner_path} is not covered by any content.json rule')

Try / catch

try:
    ws.api.siteSign(inner_path=inner_path)
except Exception as e:
    if str(e).startswith('Invalid content.json file'):
        update_content_json_includes(inner_path)  # add include pattern, re-sign
    else:
        raise

Prevention

When it happens

Trigger: Calling siteSign (via the UiWebsocket API) with an inner_path that (a) does not exist in the site's content.json rules, (b) is misspelled, or (c) is excluded from all content.json includes patterns, and the path doesn't end with 'content.json'.

Common situations: Signing a newly created file before adding it to the content.json 'files' include pattern; typo in inner_path; trying to sign files in a directory not covered by any include; permission/ownership mismatches in user content.

Related errors


AI-assisted analysis of HelloZeroNet/ZeroNet@454c0b2e7e (2026-09-02). Data as JSON: /api/errors/4cd6a4897e1102d4. Report an issue: GitHub.