## TL;DR
Context imports fail when the file came from a different ZAP version with a changed format, references authentication scripts or files by paths that do not exist on this box, or was edited by hand into invalid structure. Export a fresh context from the installed ZAP to learn its current shape, repair or recreate the failing context against that shape, and import again.

```text
zap failed to import context file for authorized scan
```

## Use this when
- Importing a .context file for an authorized scan errors, or imports with its authentication and scope missing.
- The context was shared by a teammate on a different machine or ZAP version.

## Not for this skill when
- The context imports and shows correctly, but scans ignore it. That is a session or scan policy selection problem.
- The file is a ZAP session or plan file, not a context. Import each artifact through its own route.

## Steps
1. Read the ZAP log and the import error in full; note whether it complains about structure, a missing script, or a missing file path. Verify: Verify: the failure class is named before you change anything.
2. Create a throwaway context in this ZAP install with one include rule and export it, then compare its structure with the failing file section by section. Verify: Verify: format differences between the two files are visible and listed.
3. Fix machine-specific references in the failing context: authentication scripts, certificate files, and any absolute paths, pointing them at files that exist on this tester box. Verify: Verify: every referenced path in the file exists on disk.
4. Repair or rebuild the context to match the current format, then import it into a fresh session. Verify: Verify: the import completes and the context shows its include rules, authentication, and users.
5. Prove it works: browse one authorized URL and confirm ZAP tags it as in the imported context, and check the logged-in indicator behaves. Verify: Verify: the URL shows the context marker and session handling uses the imported settings.

## Variant phrasings
### zap context import failed version format mismatch
The version phrasing.
### zap context authentication script path not found
The missing-file phrasing.
### zap imported context missing scope rules
The partial-import phrasing.

Compatibility: Compatibility: OWASP ZAP 2.x context files; contexts are not guaranteed portable across major versions or operating systems.

## Why it happens
A context bundles scope rules, authentication method, scripts, and file references in one serialized file. Any one stale reference can fail the whole import, and version changes alter the serialization. Because teammates share contexts between machines, path and version drift is the normal cause, not corruption of the assessment itself.

## Edge cases / pitfalls
- Contexts can embed credentials or session settings; share them only through the engagement's approved channels and treat the file as sensitive.
- Hand-editing context XML is error-prone; prefer rebuilding through the UI when more than paths are wrong.
- After import, re-check exclusions: an imported context may exclude paths the current engagement actually wants tested.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_Eu7Vq6oPObEkjuQlgLIr0w
