tools: print the error body the Library endpoint returns
The pairing came back perfectly clean, and it is the whole diagnosis:
has library_file_id → refused (11/11)
no library_file_id → deleted (7/7)
And /files/{libfile_id}/download answered 200 — not 403, not 404 — with
{status, error_code, error_type, error_message}. That endpoint accepts the
Library id; it is returning an application-level error inside an HTTP 200.
The probe printed only the keys and dropped the message, which is the one
thing that says what the call is missing.
- show() now prints the full body for every response, and detects a
non-JSON 200 as possible raw bytes.
- Added routes worth ruling in or out: the same call as POST, with a
conversation_id, /files/{lib}/content, /content?asset_pointer=, and four
Library listing endpoints — a listing usually reveals both the id form
the UI uses and the route that actually serves bytes.
- Probes a second Library id too, so one odd file cannot mislead us.
This commit is contained in:
@@ -80,7 +80,7 @@ def main() -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
provider = ChatGPTProvider()
|
provider = ChatGPTProvider()
|
||||||
pairs: list[tuple[str, str]] = []
|
pairs: list[tuple[str, str, str]] = []
|
||||||
|
|
||||||
print("=" * 78)
|
print("=" * 78)
|
||||||
print("Pairing refused assets with their Library IDs")
|
print("Pairing refused assets with their Library IDs")
|
||||||
@@ -98,61 +98,78 @@ def main() -> None:
|
|||||||
source = (att or {}).get("source")
|
source = (att or {}).get("source")
|
||||||
print(f" {file_id[:34]}… library={str(lib)[:34]:<36} source={source}")
|
print(f" {file_id[:34]}… library={str(lib)[:34]:<36} source={source}")
|
||||||
if lib:
|
if lib:
|
||||||
pairs.append((file_id, lib))
|
pairs.append((file_id, lib, conv_id))
|
||||||
|
|
||||||
if not pairs:
|
if not pairs:
|
||||||
print("\n No refused asset carries a library_file_id — different cause.")
|
print("\n No refused asset carries a library_file_id — different cause.")
|
||||||
return
|
return
|
||||||
|
|
||||||
file_id, lib_id = pairs[0]
|
file_id, lib_id, conv_id = pairs[0]
|
||||||
print()
|
print()
|
||||||
print("=" * 78)
|
print("=" * 78)
|
||||||
print(f"Endpoint hunt for {lib_id}")
|
print(f"Endpoint hunt for {lib_id}")
|
||||||
print(f" (sediment id {file_id})")
|
print(f" (sediment id {file_id})")
|
||||||
print("=" * 78)
|
print("=" * 78)
|
||||||
|
|
||||||
def show(label: str, url: str) -> bool:
|
def show(label: str, url: str, method: str = "GET") -> bool:
|
||||||
|
"""Print status AND body. A 200 carrying an error envelope says what
|
||||||
|
the endpoint wants — printing only the keys threw that away."""
|
||||||
try:
|
try:
|
||||||
provider._pace()
|
provider._pace()
|
||||||
resp = provider._session.request("GET", url, timeout=30)
|
resp = provider._session.request(method, url, timeout=30)
|
||||||
except Exception as e: # noqa: BLE001 - diagnostic
|
except Exception as e: # noqa: BLE001 - diagnostic
|
||||||
print(f" {label:<50} error {type(e).__name__}")
|
print(f" {label:<50} error {type(e).__name__}")
|
||||||
return False
|
return False
|
||||||
note = ""
|
|
||||||
hit = False
|
hit = False
|
||||||
if resp.status_code == 200:
|
try:
|
||||||
try:
|
body = resp.json()
|
||||||
body = resp.json()
|
except Exception: # noqa: BLE001 - diagnostic
|
||||||
if isinstance(body, dict) and body.get("download_url"):
|
preview = (resp.text or "").strip()[:200]
|
||||||
note = " ← DOWNLOAD URL"
|
if resp.status_code == 200 and resp.content:
|
||||||
hit = True
|
print(f" {label:<50} 200 non-JSON ({len(resp.content)} bytes) ← BYTES?")
|
||||||
else:
|
return True
|
||||||
keys = list(body)[:8] if isinstance(body, dict) else type(body).__name__
|
print(f" {label:<50} {resp.status_code} {preview}")
|
||||||
note = f" 200 keys={keys}"
|
return False
|
||||||
except Exception: # noqa: BLE001 - diagnostic
|
|
||||||
note = f" 200 non-JSON ({len(resp.content)} bytes)"
|
if isinstance(body, dict) and body.get("download_url"):
|
||||||
hit = True
|
print(f" {label:<50} {resp.status_code} ← DOWNLOAD URL")
|
||||||
print(f" {label:<50} {resp.status_code}{note}")
|
print(f" {json.dumps(body, default=str)[:300]}")
|
||||||
|
return True
|
||||||
|
|
||||||
|
print(f" {label:<50} {resp.status_code}")
|
||||||
|
print(f" {json.dumps(body, default=str)[:400]}")
|
||||||
return hit
|
return hit
|
||||||
|
|
||||||
candidates = [
|
candidates = [
|
||||||
|
# This one already returns 200 with an error envelope — read it.
|
||||||
("/files/{lib}/download", f"{BASE_URL}/files/{lib_id}/download"),
|
("/files/{lib}/download", f"{BASE_URL}/files/{lib_id}/download"),
|
||||||
("/files/{lib}", f"{BASE_URL}/files/{lib_id}"),
|
("/files/{lib}/download?conversation_id=", f"{BASE_URL}/files/{lib_id}/download?conversation_id={conv_id}"),
|
||||||
("/library/files/{lib}/download", f"{BASE_URL}/library/files/{lib_id}/download"),
|
("/files/{lib}/download (POST)", f"{BASE_URL}/files/{lib_id}/download"),
|
||||||
("/library/files/{lib}", f"{BASE_URL}/library/files/{lib_id}"),
|
# How does the UI enumerate the Library? A listing tends to reveal both
|
||||||
("/library/{lib}", f"{BASE_URL}/library/{lib_id}"),
|
# the id form it uses and the route that serves bytes.
|
||||||
(
|
("/library/files?limit=3", f"{BASE_URL}/library/files?limit=3"),
|
||||||
"/files/{sediment}/download?library_file_id=",
|
("/library?limit=3", f"{BASE_URL}/library?limit=3"),
|
||||||
f"{BASE_URL}/files/{file_id}/download?library_file_id={lib_id}",
|
("/files?limit=3", f"{BASE_URL}/files?limit=3"),
|
||||||
),
|
("/my_files?limit=3", f"{BASE_URL}/my_files?limit=3"),
|
||||||
("/files/{lib}/download?use_case=gizmo", f"{BASE_URL}/files/{lib_id}/download?use_case=gizmo"),
|
# Content routes that serve the asset rather than a signed URL.
|
||||||
|
("/files/{lib}/content", f"{BASE_URL}/files/{lib_id}/content"),
|
||||||
|
("/content?asset_pointer=sediment://{sediment}", f"{BASE_URL}/content?asset_pointer=sediment://{file_id}"),
|
||||||
]
|
]
|
||||||
|
|
||||||
winners = []
|
winners = []
|
||||||
for label, url in candidates:
|
for label, url in candidates:
|
||||||
if show(label, url):
|
method = "POST" if "(POST)" in label else "GET"
|
||||||
|
if show(label, url, method):
|
||||||
winners.append((label, url))
|
winners.append((label, url))
|
||||||
|
|
||||||
|
# If a second file behaves differently, the first one was the anomaly.
|
||||||
|
if len(pairs) > 1:
|
||||||
|
_other_file, other_lib, _other_conv = pairs[1]
|
||||||
|
print()
|
||||||
|
print(f" --- second sample: {other_lib} ---")
|
||||||
|
show("/files/{lib}/download", f"{BASE_URL}/files/{other_lib}/download")
|
||||||
|
|
||||||
print()
|
print()
|
||||||
print("=" * 78)
|
print("=" * 78)
|
||||||
print("Result")
|
print("Result")
|
||||||
|
|||||||
Reference in New Issue
Block a user