lablup / lablup/backend.ai

Update InvalidImageTag Exception Handling

Open
#5,985 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
17h 7m
Merged PRs (30d)
358

Description

## Motivation

The current `InvalidImageTag` exception in `src/ai/backend/common/exception.py:62` is too restrictive and causes hard failures when encountering non-conforming but potentially valid image tags. This prevents the system from importing legitimate images from external registries and disrupts workflows. We need to make the exception handling more permissive while maintaining appropriate logging for monitoring purposes.

## Required Features

- **Graceful degradation**: Convert critical failures to warnings where image processing can continue
- **Enhanced logging**: Add detailed logging for validation events to aid debugging and monitoring
- **Selective enforcement**: Distinguish between truly invalid tags and format variations
- **Fallback processing**: Allow image processing to continue with unparseable tags
- **Maintain security**: Ensure relaxed validation doesn't introduce security vulnerabilities

## Impact

### Primary Components

- `src/ai/backend/common/exception.py:62` - InvalidImageTag class definition
- Exception handling throughout the image processing pipeline
- Registry scanning error handling logic

### Secondary Components

- Image import workflows that catch InvalidImageTag exceptions
- API error responses for image validation failures
- Admin interface error display for image operations

### Services Affected

- Registry scanning services (automated image discovery)
- Manager service image validation
- Image import and synchronization processes

## Testing Scenarios

### Exception Handling Tests

- Verify previously failing tags now generate warnings instead of exceptions
- Test that truly invalid tags (empty, null, dangerous characters) still fail appropriately
- Confirm logging captures validation events with appropriate detail levels

### Workflow Continuity Tests

- Registry scanning completes successfully despite tag format variations
- Image import processes handle mixed tag formats gracefully
- Batch operations continue processing after encountering non-conforming tags

### Security Validation Tests

- Ensure relaxed validation doesn't allow injection attacks
- Verify dangerous characters and patterns are still rejected
- Test that system stability is maintained with various tag inputs

### Monitoring and Debugging Tests

- Validate log messages provide sufficient detail for troubleshooting
- Confirm metrics and alerts work with new warning-based approach
- Test error reporting maintains visibility into validation issues

JIRA Issue: BA-2460

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.