In most cases, load all images in setup() to preload them at the start of the program. Loading images inside draw() will reduce the speed of a program. Images cannot be loaded outside setup() unless they’re inside a function that’s called after setup() has already run.
So this is definitely not a bug. But I don’t know if Processing enforces that or it cannot load an image because the setup function does something in particular (setting the sketch path? As stated in the error…)
Just to elaborate – load images and set sketch size in setup() or settings(), as described above. However, this is a designed limitation for full sketches with setup() etc. – it isn’t a limitation related to the sketch path itself. Unsaved sketches are just sketches in a temporary directory that have not yet been renamed and moved into the main file path, and immediate mode sketches without setup() can always load images just fine, whether or they are saved or “unsaved” (which is really just located in a temporary directory).
Try opening a new, unsaved sketch window, enter this snippet of code and run without saving: