Skip to content

Conversation

@yuancjun
Copy link
Contributor

@yuancjun yuancjun commented Aug 2, 2025

Replace unwrap() calls with proper error handling when processing uploaded files.
When no filename is provided, the server now logs a warning and continues
processing instead of panicking.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

2025-08-02-upload.txt

  Replace unwrap() calls with proper error handling when processing uploaded files.
  When no filename is provided, the server now logs a warning and continues
  processing instead of panicking.

  🤖 Generated with [Claude Code](https://claude.ai/code)

  Co-Authored-By: Claude <noreply@anthropic.com>
println!("[Warning]: Invalid filename: {}", raw_filename);
continue;
}
};
Copy link
Owner

Choose a reason for hiding this comment

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

Please use if-let-else here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TheWaWaR

  • Use if-let-else pattern for both filename extraction and validation ✅

Copy link
Owner

@TheWaWaR TheWaWaR Aug 2, 2025

Choose a reason for hiding this comment

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

let Some(raw_filename) = headers.filename.clone() else {
    println!("[Warning]: Skipping field with no filename");
    continue;
};

Copy link
Owner

Choose a reason for hiding this comment

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

Please run cargo fmt for your code.

@yuancjun
Copy link
Contributor Author

yuancjun commented Aug 2, 2025

Screenshot 2025-08-02 at 4 03 39 PM

  - Replace unwrap() calls with proper error handling when processing uploaded files
  - Use if-let pattern for filename validation as requested
  - When no filename is provided, server now logs warning and continues instead of panicking

  🤖 Generated with [Claude Code](https://claude.ai/code)

  Co-Authored-By: Claude <noreply@anthropic.com>
  - Replace unwrap() calls with proper error handling when processing uploaded files
  - Use if-let-else pattern for both filename extraction and validation
  - When no filename is provided, server now logs warning and continues instead of panicking

  🤖 Generated with [Claude Code](https://claude.ai/code)

  Co-Authored-By: Claude <noreply@anthropic.com>
  - Replace unwrap() calls with proper error handling when processing uploaded files
  - Use if-let-else pattern for both filename extraction and validation
  - When no filename is provided, server now logs warning and continues instead of panicking

  🤖 Generated with [Claude Code](https://claude.ai/code)

  Co-Authored-By: Claude <noreply@anthropic.com>
- Replace unsafe unwrap() calls with safe if-let-else pattern
  - Add proper validation for missing and invalid filenames
  - Skip malformed uploads with warning messages instead of panicking
  - Use modern Rust idioms for cleaner error handling

  Addresses potential crashes when users upload files without proper
  filename headers or with invalid path names.
  - Replace unsafe unwrap() calls with safe if-let-else pattern
  - Add proper validation for missing and invalid filenames
  - Skip malformed uploads with warning messages instead of panicking
  - Use modern Rust idioms for cleaner error handling

  Addresses potential crashes when users upload files without proper
  filename headers or with invalid path names.
@TheWaWaR TheWaWaR merged commit 4beb0fc into TheWaWaR:master Aug 3, 2025
11 checks 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.

2 participants