Problem
In filter.go and main.go, filter configuration loading has several issues:
- Relative path failure in Lambda:
LoadFilterConfig hardcodes relative path filepath.Join("filters", ...). In AWS Lambda custom runtimes, the working directory may not be the task root or where the binary is executed. In Dockerfile.lambda, filters are copied to ${LAMBDA_TASK_ROOT}/filters/. If the process is invoked from another working directory, os.Stat fails to find the filter files.
- Disk I/O on every SQS invocation:
filterConfig, err := LoadFilterConfig(filterName) is called on every Lambda invocation in the handler loop instead of during initialization or cached in memory.
- Silent fallback hides configuration errors:
If a non-existent DAS_FILTER_NAME is specified and no default files exist, LoadFilterConfig silently returns an empty FilterConfig (Drop: [], Query: {}) with err == nil. The operator has no visibility that their custom filter was never loaded.
Proposed Solution
- Support path resolution: check
DAS_FILTER_DIR environment variable first, then filepath.Join(os.Getenv("LAMBDA_TASK_ROOT"), "filters"), then relative filters/.
- Cache the loaded
*FilterConfig in memory so warm Lambda invocations don't perform disk I/O on each message.
- Return an explicit error or structured log warning if a specified filter name cannot be found and fallback to default occurs.
Acceptance Criteria
Problem
In filter.go and main.go, filter configuration loading has several issues:
LoadFilterConfighardcodes relative pathfilepath.Join("filters", ...). In AWS Lambda custom runtimes, the working directory may not be the task root or where the binary is executed. In Dockerfile.lambda, filters are copied to${LAMBDA_TASK_ROOT}/filters/. If the process is invoked from another working directory,os.Statfails to find the filter files.filterConfig, err := LoadFilterConfig(filterName)is called on every Lambda invocation in the handler loop instead of during initialization or cached in memory.If a non-existent
DAS_FILTER_NAMEis specified and no default files exist,LoadFilterConfigsilently returns an emptyFilterConfig(Drop: [],Query: {}) witherr == nil. The operator has no visibility that their custom filter was never loaded.Proposed Solution
DAS_FILTER_DIRenvironment variable first, thenfilepath.Join(os.Getenv("LAMBDA_TASK_ROOT"), "filters"), then relativefilters/.*FilterConfigin memory so warm Lambda invocations don't perform disk I/O on each message.Acceptance Criteria
${LAMBDA_TASK_ROOT}/filters