Skip to content

fix: apply --url can submit to a completely different job than the one targeted#65

Open
sebastianmukuria wants to merge 1 commit into
Pickle-Pixel:mainfrom
sebastianmukuria:fix/target-url-exact-match
Open

fix: apply --url can submit to a completely different job than the one targeted#65
sebastianmukuria wants to merge 1 commit into
Pickle-Pixel:mainfrom
sebastianmukuria:fix/target-url-exact-match

Conversation

@sebastianmukuria

Copy link
Copy Markdown

The bug

acquire_job's target-url lookup builds its fallback LIKE pattern by stripping the query string:

like = f"%{target_url.split('?')[0].rstrip('/')}%"
WHERE (url = ? OR application_url = ? OR application_url LIKE ? OR url LIKE ?)

On indeed and linkedin the query string is the job identity (?jk=…, currentJobId=…), so the pattern collapses to %indeed.com/viewjob% — which matches every indeed job in the database. Since the exact and LIKE conditions are OR'd in one query with LIMIT 1 and no ORDER BY, SQLite returns an arbitrary matching row.

Impact: running applypilot apply --url <job A> can silently select job B and submit the candidate's application to a different company. Observed in the wild: targeting one indeed posting ran a different company's application twice in a row.

The fix

  1. Exact match on url / application_url first.
  2. Only if nothing matches exactly, fall back to a LIKE that tolerates scheme and trailing-slash variants of the same URL — with the query string preserved.
  3. No match → None (the caller reports no job found), never someone else's job.

Three regression tests included (tests/test_target_url_match.py): query-string identity is respected, unknown URLs return None rather than falling back, and scheme/trailing-slash variants still resolve.

🤖 Generated with Claude Code

acquire_job's target-url fallback stripped the query string to build its
LIKE pattern -- but on indeed/linkedin the query string IS the job identity
(?jk=, currentJobId=). The pattern '%indeed.com/viewjob%' matched every
indeed job in the DB, and LIMIT 1 then applied to an arbitrary one: clicking
apply for one posting could fill out a completely different company's
application (observed in the wild: targeting one indeed job ran another
company's job twice).

Now: exact match on url/application_url first; the only fallback is a LIKE
for scheme/trailing-slash variants of the SAME url with the query string
preserved; no match returns None instead of someone else's job. Three
regression tests included.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant