Skip to content

fix: initialize res = None to prevent UnboundLocalError#1614

Open
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix/unbound-local-error-res
Open

fix: initialize res = None to prevent UnboundLocalError#1614
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix/unbound-local-error-res

Conversation

@Jah-yee
Copy link

@Jah-yee Jah-yee commented Mar 13, 2026

Summary

When no converter accepts the file, res is referenced before assignment causing UnboundLocalError at line 616.

Fix

Initialize res = None before the converter loop to fix this issue.

Test

The bug was triggered when:

  1. A file is passed to MarkItDown.convert()
  2. No converter accepts the file (all converter.accepts() return False)
  3. The code tries to check if res is not None: but res was never defined

Related

Fixes #81

When no converter accepts the file, res is referenced before assignment
causing UnboundLocalError at line 616. Initialize res = None before
the converter loop to fix this issue.

Fixes microsoft#81
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.

UnboundLocalError: local variable 'res' referenced before assignment

1 participant