Skip to content

[LFXV2-1194] fix: soft delete, tombstone dedup, and lint fixes#10

Merged
andrest50 merged 7 commits intomainfrom
andrest50/fix-delete-events
Mar 5, 2026
Merged

[LFXV2-1194] fix: soft delete, tombstone dedup, and lint fixes#10
andrest50 merged 7 commits intomainfrom
andrest50/fix-delete-events

Conversation

@andrest50
Copy link
Contributor

@andrest50 andrest50 commented Mar 4, 2026

Summary

  • Add soft delete detection via _sdc_deleted_at field in KV PUT entries
  • Introduce tombstone marker (!del) to prevent duplicate delete events on KV message redelivery
  • Refactor delete path into shared handleResourceDelete removing unused idMapper param
  • Fix lostcancel govet lint: remove defer eventProcessorCancel() from conditional block
  • Fix gofmt alignment of EventConsumerName/EventStreamName in loadConfig
  • Fix hadolint DL3025: remove || exit 1 from Dockerfile exec-form HEALTHCHECK CMD
  • Fix shellcheck SC2162: add -r flag to both read calls in scripts/delete_survey_documents.sh
  • Add revive.toml linter config and .mega-linter.yml

Ticket

LFXV2-1194

🤖 Generated with Claude Code

- Detect soft deletes via _sdc_deleted_at field in KV PUT entries and
  route them through the same delete path as hard deletes
- Replace hard mapping deletion with a tombstone marker (!del) to prevent
  duplicate delete events when KV deletes are redelivered
- Refactor handleKVDelete into handleResourceDelete shared by both hard
  and soft delete paths; remove unused idMapper parameter from delete path
- Add defer eventProcessorCancel() to fix context cancel leak in main

Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Andres Tobon <andrest2455@gmail.com>
- Remove `|| exit 1` from Dockerfile HEALTHCHECK exec-form CMD (hadolint DL3025)
- Fix gofmt alignment of EventConsumerName/EventStreamName in loadConfig (golangci-lint)
- Remove defer eventProcessorCancel() inside conditional block to fix lostcancel (golangci-lint govet)
- Add -r flag to both read calls in delete_survey_documents.sh (shellcheck SC2162)
- Add revive.toml linter config and .mega-linter.yml

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

Signed-off-by: Andres Tobon <andrest2455@gmail.com>
Copilot AI review requested due to automatic review settings March 4, 2026 22:00
Copy link

Copilot AI left a comment

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 improves survey-service event processing around deletes (soft deletes and KV redelivery deduplication) and adds/updates linting configuration to address multiple static analysis findings.

Changes:

  • Detect soft deletes via _sdc_deleted_at on KV PUT entries and route them through the delete path.
  • Add a tombstone marker (!del) in the mappings KV to deduplicate delete events on redelivery, and refactor delete handling into a shared helper.
  • Apply assorted lint/config fixes (shellcheck, hadolint, gofmt) and introduce revive.toml + .mega-linter.yml.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
scripts/delete_survey_documents.sh Adds read -r to satisfy shellcheck and avoid backslash escaping issues.
revive.toml Adds revive configuration and disables specific rules for this repo.
cmd/survey-api/main.go gofmt alignment in loadConfig.
cmd/survey-api/eventing/survey_response_event_handler.go Tombstone-based delete dedup for survey responses.
cmd/survey-api/eventing/survey_event_handler.go Tombstone-based delete dedup for surveys.
cmd/survey-api/eventing/kv_handler.go Soft delete detection + shared delete handler + tombstone helpers.
Dockerfile Fixes HEALTHCHECK exec-form per hadolint guidance.
.mega-linter.yml Adds MegaLinter configuration.

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

…yamllint config

- Pin cgr.dev/chainguard/go and static images by SHA digest (hadolint DL3007)
- Fix lostcancel govet: call eventProcessorCancel before return 1 in srv.Shutdown error path
- Upgrade go.opentelemetry.io/otel to v1.40.0 (fixes GHSA-9h8m-3fm2-qjrq)
- Add .yamllint config

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

Signed-off-by: Andres Tobon <andrest2455@gmail.com>
…rect mega-linter config

- Treat tombstoned survey mapping as not-found when checking parent exists for survey responses
- Fix lostcancel: initialize eventProcessorCtx/Cancel unconditionally with defer to cover all return paths
- Fix KUBERNETES_DIRECTORY and KUBERNETES_HELM_ARGUMENTS to point to charts/lfx-v2-survey-service
- Fix revive.toml ignoreGeneratedHeader comment to accurately describe true/false behavior

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

Signed-off-by: Andres Tobon <andrest2455@gmail.com>
- Remove redundant context.WithCancel reassignment inside if block; use
  single context created upfront with defer to cover all return paths (lostcancel)
- Move YAML document separator inside {{- if }} block in serviceaccount.yaml
  to fix helm lint parse error
- Upgrade go.opentelemetry.io/otel/sdk to v1.40.0 (fixes GHSA-9h8m-3fm2-qjrq)

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

Signed-off-by: Andres Tobon <andrest2455@gmail.com>
- Add tombstone deduplication, soft delete support, and orphan prevention
  sections to event-processing.md deduplication documentation
- Fix duplicate processing troubleshooting entry to reference tombstone marker
- Add LOG_LEVEL and LOG_ADD_SOURCE env var descriptions to itx-proxy-implementation.md
- Fix NewSurveyService parameter order in test example
- Update LOC count to reflect event processing additions

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

Signed-off-by: Andres Tobon <andrest2455@gmail.com>
Rules exported and unused-parameter no longer need to be disabled
as the codebase already satisfies them.

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

Signed-off-by: Andres Tobon <andrest2455@gmail.com>
@andrest50 andrest50 merged commit 29bc4a8 into main Mar 5, 2026
5 checks passed
@andrest50 andrest50 deleted the andrest50/fix-delete-events branch March 5, 2026 16:44
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