Fix the cause and check for regressions
Reproduce a broken contact link, ask Codex for a one-line repair, inspect the actual diff, and check both the page and the automated result.
Finish the first-task lesson. Download the bug lab separately from the starter. Git enables the diff; Node.js 22+ runs the included check. If either is unavailable, record that check as NOT RUN and use the file/browser comparison.
WHAT · What you will learn
This lab deliberately contains a wrong anchor: the contact link points to #contact-missing while the section ID is contact. The repair should change only that href, leaving the content and layout intact.
WHY · Why this matters
Changing a heading, restyling the page, or deleting a failing check would not explain the failure. A reproduced symptom and a narrow diff make the cause and the repair easy to review.
HOW · Follow the steps
- Extract codeway-bug-lab into a separate folder. Read the localized README, REQUIREMENTS and VERIFY. Open index.en.html and activate Contact: the URL changes to #contact-missing.
- In this practice folder only, initialize Git and stage the unchanged HTML as your before-state. A commit or a GitHub account is not needed to compare an unstaged edit with the index.
- Run the included check once before the fix. Expect a nonzero exit code for the missing anchor. This is the deliberate failure to repair.
- Send the repair prompt below. Then inspect the diff before staging the changed file. Keep the check script unchanged.
git init
git add index.en.html
node verify.mjs enEXAMPLE · A worked example
Before: href="#contact-missing". Existing target: <section id="contact">. After: href="#contact". The reference repair changes one line; the verification script and page text are unchanged.
Open the reference folder only after your attempt. It contains the corrected HTML for comparison, not evidence that your working copy has been fixed. Run your own checks against your working copy.
In index.en.html, the Contact link changes the URL to #contact-missing but does not reach the contact section.
Read index.en.html and verify.mjs. Reproduce the failure with node verify.mjs en.
Fix only the wrong contact href in index.en.html. Preserve all other content and files.
Run node verify.mjs en again, then show git diff -- index.en.html.
Report the cause, the changed line, the actual check results, and any browser checks you did not run.
Do not change the tests, install packages, commit, push, or deploy.TRY IT · Do it yourself
- Repeat the exercise with the back-to-top link in a fresh copy: change its target to a nonexistent ID, reproduce the failure, and request the smallest repair.
- Predict the failing check before running it. Do not weaken the checks to make the exercise pass.
VERIFY · Check the evidence
- Diff: git diff -- index.en.html shows only the intended href change. Other files and the verification script remain unchanged.
- Automated check: node verify.mjs en now returns exit code 0. Keep the earlier failing result to demonstrate that the check could detect the bug.
- Browser: reload the working page and activate Contact with a mouse, then with Tab and Enter. Confirm #contact is reached; also check Back to top.
- Mobile: at 390px, the link remains readable and usable, and the page does not scroll sideways. A structural script alone cannot establish these outcomes.
COMMON ERRORS · Recognize the failure
- Testing reference/index.en.html instead of the working file creates a false pass.
- Staging the repair before reading the diff makes the default unstaged diff empty.
- Changing the section ID instead of the broken link can break other links to that section.
FIX · Recover deliberately
- Wrong file: reopen the HTML at the root of your working folder and repeat the failing action.
- Empty diff after staging: use git diff --cached -- index.en.html to inspect staged changes. Compare with the original lab file too; the initial staged file is not a published commit.
- Check script changed: keep both copies, restore the original check from the ZIP, and run it against the repaired HTML. A changed test cannot prove the original requirement was met.
NEXT · Continue when ready
Keep the before failure, one-line diff, and after checks together. The next lesson turns these into a clear acceptance report and tests what is still unknown.
Sources and scope
Independent practice content. Product guidance reviewed on 16 September 2026. Reference HTML and expected outcomes are distinguished from actual recorded runs.
OpenAI · Code review ↗Git · git diff ↗MDN · HTML links ↗