Skip to content

[Code scan] Preserve explicit cloud tickets and per-job log offsets #614

Description

@njzjz

Found by a Codex global repository scan of deepmodeling/dpdispatcher at commit 98a9e08.

Problem
The cloud client overwrites an explicit constructor ticket from BOHR_TICKET on every request/refresh, and it tracks log download offset in one shared integer across all jobs.

Relevant code

self.last_log_offset = 0
self.ticket = ticket

if not self.token:
self.refresh_token()
self.ticket = os.environ.get("BOHR_TICKET", "")
header["Authorization"] = f"jwt {self.token}"
header["Brm-Ticket"] = self.ticket

def refresh_token(self, retry=3):
self.ticket = os.environ.get("BOHR_TICKET", "")
if self.ticket:
return
url = "/account/login"
post_data = {"email": self.config["email"], "password": self.config["password"]}

def get_log(self, job_id):
url, size = self._get_job_log(job_id)
if not url:
return ""
if self.last_log_offset >= size:
return ""
resp = requests.get(url, headers={"Range": f"bytes={self.last_log_offset}-"})
self.last_log_offset += len(resp.content)

Impact
Client(ticket="...") is ignored unless BOHR_TICKET is also set, causing unexpected password-login attempts. When polling logs for multiple jobs, reading job A advances the single offset and can skip job B's logs.

Suggested fix
Preserve an explicit constructor ticket unless a non-empty environment override is intentionally provided. Track log offsets per job id, for example dict[str, int] keyed by job_id.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions