Skip to content

Ignore shared URLs in file processor#3037

Merged
veloce merged 2 commits into
lichess-org:mainfrom
HaonRekcef:remove-unneeded-file-read
Apr 27, 2026
Merged

Ignore shared URLs in file processor#3037
veloce merged 2 commits into
lichess-org:mainfrom
HaonRekcef:remove-unneeded-file-read

Conversation

@HaonRekcef

Copy link
Copy Markdown
Collaborator

I noticed while debugging that there was an unnecessary attempted file read when opening a deeplink url as ReceiveSharingIntent would also handle it.
I/flutter (13335): Failed to process incoming file: PathNotFoundException: Cannot open file, path = 'https://lichess.org/iMypvkd1' (OS Error: No such file or directory, errno = 2)

Copilot AI 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.

Pull request overview

This PR prevents the shared-file processor from attempting to read HTTP(S) deep links as local files, avoiding PathNotFoundException noise when a URL is shared/opened and ReceiveSharingIntent delivers it as a “file”.

Changes:

  • Add an early-return in _processSharedFiles when the shared path is an http:// or https:// URL.
  • Emit a diagnostic log when a shared URL is ignored.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/src/app.dart Outdated
Comment on lines +209 to +211
if (filePath.startsWith('https://') || filePath.startsWith('http://')) {
debugPrint('Ignored shared URL in file processor: $filePath');
return;

Copilot AI Apr 24, 2026

Copy link

Choose a reason for hiding this comment

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

debugPrint logs the full shared URL ($filePath). Shared URLs can include private paths or query parameters, so avoid printing the full value in logs (especially in release). Consider guarding this log with kDebugMode, or logging only the scheme/host (or a redacted version).

Copilot uses AI. Check for mistakes.
Comment thread lib/src/app.dart Outdated
Future<void> _processSharedFiles(List<SharedMediaFile> files) async {
if (files.isEmpty) return;
final filePath = files.first.path;
if (filePath.startsWith('https://') || filePath.startsWith('http://')) {

Copilot AI Apr 24, 2026

Copy link

Choose a reason for hiding this comment

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

The URL detection uses startsWith('https://') || startsWith('http://'), which is a brittle string check (e.g., it can miss valid URLs with different casing or leading whitespace). Using Uri.tryParse(filePath) and checking uri.scheme (case-insensitive) would be more robust and self-documenting.

Suggested change
if (filePath.startsWith('https://') || filePath.startsWith('http://')) {
final uri = Uri.tryParse(filePath.trimLeft());
final scheme = uri?.scheme.toLowerCase();
if (scheme == 'https' || scheme == 'http') {

Copilot uses AI. Check for mistakes.
Comment thread lib/src/app.dart Outdated
@veloce veloce merged commit 4c10e02 into lichess-org:main Apr 27, 2026
1 check passed
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