Skip to content

fix(OpenAiAPIService): Throw UserFacingProcessingException if service is not responding properly#380

Merged
marcelklehr merged 8 commits into
mainfrom
fix/user-facing-error-500
Jun 16, 2026
Merged

fix(OpenAiAPIService): Throw UserFacingProcessingException if service is not responding properly#380
marcelklehr merged 8 commits into
mainfrom
fix/user-facing-error-500

Conversation

@marcelklehr

Copy link
Copy Markdown
Member

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@marcelklehr marcelklehr requested a review from julien-nc June 15, 2026 06:35
@marcelklehr marcelklehr marked this pull request as draft June 15, 2026 06:38
… is not responding properly

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@marcelklehr marcelklehr force-pushed the fix/user-facing-error-500 branch from 3724466 to 7bef1b3 Compare June 15, 2026 06:40

@julien-nc julien-nc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UserFacingProcessingException is caught in the providers and RuntimeException is thrown instead. Check the catch block at the end of TextToTextProvider for example. We should probably make a special case and let UserFacingProcessingException propagate to the upper level.

Naive fix:

} catch (Exception $e) {
	if ($e instanceof UserFacingProcessingException) {
		throw $e;
	}
	throw new RuntimeException('OpenAI/LocalAI request failed: ' . $e->getMessage());
}

@kyteinsky

Copy link
Copy Markdown
Contributor

or maybe

} catch (UserFacingProcessingException $e) {
	throw $e;
} catch (Exception $e) {
	throw new RuntimeException('OpenAI/LocalAI request failed: ' . $e->getMessage());
}

Comment thread lib/Service/OpenAiAPIService.php
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@marcelklehr marcelklehr marked this pull request as ready for review June 16, 2026 09:43
@marcelklehr

Copy link
Copy Markdown
Member Author

I'm not bothering to fix psalm. Julien's PR does that already.

Comment on lines -122 to +123
throw new RuntimeException('Too many files given. Max is 500');
throw new ProcessingException('Too many files given. Max is 500');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe qualifies for UserFacingProcessingException

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be a different PR, let's try to not bloat up this one too much

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by all means

Comment on lines -132 to +133
throw new RuntimeException('Filesize of input files too large. Max is 50MB');
throw new ProcessingException('Filesize of input files too large. Max is 50MB');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this too

Comment on lines -137 to +138
throw new RuntimeException('Invalid input file type ' . $fileType);
throw new ProcessingException('Invalid input file type ' . $fileType);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not too sure about this one, but could be harmless if the user sees it anyway

Comment on lines -147 to +148
throw new RuntimeException('Invalid input file type for OpenAI ' . $fileType);
throw new ProcessingException('Invalid input file type for OpenAI ' . $fileType);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this too perhaps if the above is done

@kyteinsky kyteinsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Comment thread lib/Service/OpenAiAPIService.php Outdated
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Comment thread lib/Service/OpenAiAPIService.php Outdated
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@marcelklehr marcelklehr merged commit 6697357 into main Jun 16, 2026
26 checks passed
@marcelklehr marcelklehr deleted the fix/user-facing-error-500 branch June 16, 2026 13:33
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.

3 participants