Skip to content

fix(environment): raise FileNotFoundError instead of silently loading nothing - #383

Open
boring877 wants to merge 1 commit into
K0lb3:masterfrom
boring877:fix/silent-empty-environment-on-missing-path
Open

boring877 wants to merge 1 commit into
K0lb3:masterfrom
boring877:fix/silent-empty-environment-on-missing-path

Conversation

@boring877

Copy link
Copy Markdown

Problem

UnityPy.load("missing.unity3d") currently returns an empty Environment with no error. Typos and wrong paths hide behind env.objects == [] until much later in the script, where they surface as confusing "no objects found" behavior instead of the actual mistake.

There is even a commented-out raise FileNotFoundError for this exact case in load_file.

Why it is silent today

The silent skip is deliberate for internally resolved paths: #361 removed an over-eager FileNotFoundError that fired when dependency files were resolved from the current directory, and missing dependencies (packaging errors, references to Unity's global Library) are normal and must be skipped.

Change

This only affects top-level string paths passed explicitly to Environment / UnityPy.load: those are user intent, so resolving them to nothing now raises FileNotFoundError.

  • Environment.__init__ raises when load_file returns None for a top-level path
  • load_file itself is unchanged: dependency, split-file and case-insensitive fallbacks keep the silent-skip behavior Fixed loading assets from current directory #361 established
  • relative paths still resolve against the previously set self.path before raising

Tests

  • missing top-level file raises FileNotFoundError
  • missing dependency stays silent
  • folder loading and bytes loading are unaffected

Full test suite passes (52 tests).

… nothing

UnityPy.load('missing.unity3d') currently returns an empty Environment
with no error, hiding typos and wrong paths behind env.objects == [].
There is even a commented-out raise for this exact case in load_file.

This restores loud failures for top-level paths while keeping
load_file's silent-skip for missing dependencies (unshipped externals
are normal and are resolved through the same code path).

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant