affaan-m/ECC · error · ValueError
remote import exceeds
Error message
remote import exceeds {max_bytes} bytes What it means
Raised by _fetch_import_url when the downloaded body exceeds max_bytes (default 2 MiB). The function reads at most max_bytes+1 bytes and rejects anything longer, so oversized remote files are never fully buffered or parsed. It is a bounded-download safeguard against huge or hostile payloads.
Solutions
- Trim or split the remote file so it is under the size limit (default 2 MiB).
- Serve only the needed instincts and import them in multiple smaller files.
- If larger imports are legitimately required, pass/increase max_bytes when calling _fetch_import_url (with care).
- Check Content-Length with a HEAD request before fetching to warn users early.
Example fix
# before content = _fetch_import_url(url) # file is 5 MB -> raises # after content = _fetch_import_url(url, max_bytes=10 * 1024 * 1024) # explicit larger bound # or split the source file into <2 MiB chunks
Defensive patterns
Strategy: validation
Validate before calling
import urllib.request
req = urllib.request.Request(source, method="HEAD")
with urllib.request.urlopen(req, timeout=15) as r:
size = int(r.headers.get("Content-Length", 0))
if size > 2 * 1024 * 1024:
raise ValueError("remote file exceeds 2 MiB import limit") Try / catch
try:
cli_import(url=source)
except ValueError as e:
if "exceeds" in str(e):
print("remote file too large; split or trim it") Prevention
- Keep exported instinct libraries under 2 MiB or split them
- HEAD-check Content-Length before importing
- Point at curated files, not raw data dumps
- Raise max_bytes explicitly only when the source is trusted
When it happens
Trigger: Importing from a URL whose body is larger than 2 MiB — a very large instincts file, an accidentally linked archive/dump, or a server streaming an unbounded response.
Common situations: Exported instinct library grew past 2 MB over time; link points to a full data dump instead of the curated file; attacker-controlled URL used to push a large payload.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- remote import host resolves to a non-public address
- remote instinct imports require https URLs
- unsupported remote content type
- download exceeds maximum allowed size
- download failed; existing destination preserved
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/6a1eca588e450606.
Report an issue: GitHub.
Appendix: source
Thrown at skills/continuous-learning-v2/scripts/instinct-cli.py:234
raise ValueError(f"remote import host resolves to a non-public address: {host}")
return urllib.parse.urlunparse(parsed)
def _fetch_import_url(source: str, *, max_bytes: int = 2 * 1024 * 1024) -> str:
"""Fetch a validated remote instinct file with bounded size and timeout."""
url = _validate_import_url(source)
req = urllib.request.Request(url, headers={"User-Agent": "ECC-instinct-import/2"})
with urllib.request.urlopen(req, timeout=15) as response:
content_type = response.headers.get("Content-Type", "")
if content_type and not any(
allowed in content_type.lower()
for allowed in ("text/", "markdown", "yaml", "json", "octet-stream")
):
raise ValueError(f"unsupported remote content type: {content_type}")
data = response.read(max_bytes + 1)
if len(data) > max_bytes:
raise ValueError(f"remote import exceeds {max_bytes} bytes")
return data.decode("utf-8")
def _yaml_quote(value: str) -> str:
"""Quote a string for safe YAML frontmatter serialization.
Uses double quotes and escapes embedded double-quote characters to
prevent malformed YAML when the value contains quotes.
"""
escaped = value.replace('\\', '\\\\').replace('"', '\\"')
return f'"{escaped}"'
# ─────────────────────────────────────────────
# Project Detection (Python equivalent of detect-project.sh)
# ─────────────────────────────────────────────
def _git_repo_root(cwd: Optional[str] = None) -> Optional[str]:View on GitHub (pinned to 8321021c54)