Skip to content

Commit 26a8490

Browse files
authored
Merge pull request #10 from chipfoundry/fix/slim-sync-payload
Fix 403 on platform sync by slimming project.json payload
2 parents 3c0eddd + 80636fa commit 26a8490

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

chipfoundry_cli/main.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ def push(project_root, sftp_host, sftp_username, sftp_key, project_id, project_n
14501450
with open(project_json_path, "r") as f:
14511451
pj = _json.load(f)
14521452
try:
1453-
_api_put(f"/projects/{platform_id}", {"cli_project_json": pj, "cli_sync_source": "push"})
1453+
_api_put(f"/projects/{platform_id}", {"cli_project_json": _slim_project_json(pj), "cli_sync_source": "push"})
14541454
console.print("[green]✓ Platform project synced[/green]")
14551455
except SystemExit:
14561456
console.print("[yellow]⚠ SFTP upload succeeded but platform sync failed[/yellow]")
@@ -1595,7 +1595,7 @@ def pull(project_name, output_dir, sftp_host, sftp_username, sftp_key):
15951595
import json as _json
15961596
with open(local_pj, "r") as f:
15971597
pj = _json.load(f)
1598-
_api_put(f"/projects/{platform_id}", {"cli_project_json": pj, "cli_sync_source": "pull"})
1598+
_api_put(f"/projects/{platform_id}", {"cli_project_json": _slim_project_json(pj), "cli_sync_source": "pull"})
15991599
console.print("[green]✓ Platform project synced[/green]")
16001600
except SystemExit:
16011601
console.print("[yellow]⚠ SFTP download succeeded but platform sync failed[/yellow]")
@@ -3753,6 +3753,20 @@ def _api_put(path: str, json_data: dict):
37533753
client.close()
37543754

37553755

3756+
_SYNC_KEEP_KEYS = {"project", "tapeout"}
3757+
3758+
3759+
def _slim_project_json(pj: dict) -> dict:
3760+
"""Return a lightweight copy of project.json for API sync.
3761+
3762+
The full file can exceed the 8 KB AWS WAF body-inspection limit when it
3763+
contains DRC results, report summaries, etc. The backend only needs the
3764+
``project`` and ``tapeout`` top-level sections; everything else is
3765+
stripped to keep the payload small.
3766+
"""
3767+
return {k: v for k, v in pj.items() if k in _SYNC_KEEP_KEYS}
3768+
3769+
37563770
def _load_project_platform_id(project_root: str):
37573771
"""Read platform_project_id from .cf/project.json, return None if absent."""
37583772
pj = Path(project_root) / '.cf' / 'project.json'

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "chipfoundry-cli"
3-
version = "2.1.0"
3+
version = "2.1.1"
44
description = "CLI tool to automate ChipFoundry project submission to SFTP server"
55
authors = ["ChipFoundry <marwan.abbas@chipfoundry.io>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)