Skip to content

fix: don't fail hybrid jobs when input symlinks are changed - #1362

Open
moneytosms wants to merge 1 commit into
amazon-braket:mainfrom
moneytosms:fix/hybrid-job-link-cleanup
Open

moneytosms wants to merge 1 commit into
amazon-braket:mainfrom
moneytosms:fix/hybrid-job-link-cleanup

Conversation

@moneytosms

@moneytosms moneytosms commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Issue #, if available:

Closes #1363

Description of changes:

clean_links in _entry_point_template.py checks link.is_symlink without calling it, so the check is always true and readlink() runs on every path. If the job deletes or replaces one of its linked input files (e.g. rewrites data.csv in place), readlink() raises inside the finally block. The job then fails even though the function returned fine, and save_job_result never runs, so the result is lost.

Also, links was only assigned inside the try, so if os.chdir or link_input() failed, the finally raised UnboundLocalError and buried the real error.

  • Call link.is_symlink()
  • Set links = {} before the try
  • Narrow the bare except: in the directory cleanup to except OSError:

Testing done:

  • Added tests for clean_links with a deleted link and a link replaced by a regular file, and for the link_input() failure case. All three fail on main (FileNotFoundError, OSError: [Errno 22] Invalid argument, UnboundLocalError) and pass with the fix.
  • Ran the rendered entry point locally against a fake container dir with a job that rewrites its input file and returns a value. On main the job fails and no results.json is written; with the fix the result is saved.
  • tox -e unit-tests (100% coverage)
  • ruff check and ruff format --check

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

clean_links checked link.is_symlink without calling it, so readlink ran on
paths the job deleted or replaced, failing the job and dropping its result.
Also init links before try so setup errors aren't masked by
UnboundLocalError.
@moneytosms
moneytosms requested a review from a team as a code owner October 1, 2026 11:01
@github-actions github-actions Bot added the aws label Oct 1, 2026
@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (fe9cb10) to head (5a39397).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1362   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          171       171           
  Lines        11667     11667           
  Branches      1539      1539           
=========================================
  Hits         11667     11667           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hybrid job fails and loses its result if a linked input file is changed

1 participant