Skip to content

Conversation

LaurenceJJones
Copy link
Contributor

fix #128

  • Add nil checks and proper error handling for utils.item_to_string calls
  • Prevent runtime errors when item_to_string returns nil values
  • Add warning logs when parsing fails to help with debugging
  • Skip processing invalid decisions gracefully instead of crashing
  • Fix issues in both stream.lua and live.lua files

This resolves the runtime error:
"attempt to concatenate local 'ip_type' (a nil value)"

The code now handles cases where IP addresses or decision values cannot be parsed and logs appropriate warnings while continuing execution.

- Add nil checks and proper error handling for utils.item_to_string calls
- Prevent runtime errors when item_to_string returns nil values
- Add warning logs when parsing fails to help with debugging
- Skip processing invalid decisions gracefully instead of crashing
- Fix issues in both stream.lua and live.lua files

This resolves the runtime error:
"attempt to concatenate local 'ip_type' (a nil value)"

The code now handles cases where IP addresses or decision values cannot be parsed
and logs appropriate warnings while continuing execution.
- Replace goto statements with proper if-else blocks for better readability
- Refactor utils.item_to_string scope checking to use elseif/else pattern
- Add explicit handling for unsupported scopes in item_to_string
- Make return value assignments more explicit with _ for ignored values
- Improve code maintainability and readability
- Eliminate duplicate calls to utils.item_to_string in deletion processing
- Use single parsing result for both deletion and cache operations
- Improve performance by reducing redundant IP parsing
- Maintain same functionality with better efficiency
Copy link
Contributor

@sabban sabban left a comment

Choose a reason for hiding this comment

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

lgtm

- Use single parsing result for both deletion and cache operations
- Improve performance by eliminating duplicate function calls
- Maintain proper captcha handling independent of key parsing
- Preserve all original functionality with better efficiency
- Use single utils.item_to_string call for both deletion and cache operations
- Maintain proper captcha handling independent of key parsing
- Improve performance while preserving all original functionality
- Ensure correct logic flow for decision processing
@LaurenceJJones LaurenceJJones merged commit 6712aba into crowdsecurity:main Oct 2, 2025
1 check passed
@LaurenceJJones LaurenceJJones deleted the fix-nil-item-to-string branch October 2, 2025 13:34
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.

[nil] utils.item_to_string
2 participants