Skip to content

feat(history): Migrate C7 external task logs to C8 job history records#1017

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/migrate-external-task-logs
Draft

feat(history): Migrate C7 external task logs to C8 job history records#1017
Copilot wants to merge 4 commits intomainfrom
copilot/migrate-external-task-logs

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

Implements migration of Camunda 7 HistoricExternalTaskLog entries to Camunda 8 JobDbModel records, completing the audit trail for external service task execution history.

Description

New migration pipeline: HistoricExternalTaskLogJobDbModel

  • ExternalTaskTransformer – maps C7 external task log fields to C8 job fields: type (topic), worker, state (CREATED/FAILED/COMPLETED/CANCELED), kind=BPMN_ELEMENT, listenerEventType=UNSPECIFIED, retries, hasFailedWithRetriesLeft, errorMessage, creationTime/endTime (based on log type), processDefinitionId, elementId, tenantId, partitionId
  • ExternalTaskMigrator – extends HistoryEntityMigrator (the refactored base class) implementing fetchForMigrateHandler(), fetchForRetryHandler(), and getType(); resolves processInstanceKey, processDefinitionKey, rootProcessInstanceKey, elementInstanceKey; skips with reason when parent entities not yet migrated
  • HISTORY_EXTERNAL_TASK type added to IdKeyMapper (auto-included in getHistoryTypes())

External task incident jobKey population

IncidentMigrator now resolves jobKey for externalTask-type incidents by:

  1. Getting externalTaskId from c7Incident.getConfiguration()
  2. Finding the failure log with retries == 0 via c7Client.getFailureExternalTaskLog()
  3. Looking up the migrated C8 key via dbClient.findC8KeyByC7IdAndType(..., HISTORY_EXTERNAL_TASK)
  4. Skipping the incident if the corresponding job has not been migrated yet (SKIP_REASON_MISSING_JOB_REFERENCE)

Migration order

External tasks are migrated after flow nodes (dependency: elementInstanceKey) and before incidents (dependency: incident jobKey):

Forms → Process Definitions → Process Instances → Flow Nodes → User Tasks → Variables
→ External Tasks (new) → Incidents → Decision Requirements → Decision Definitions → ...

Supporting changes

  • C7Client: getHistoricExternalTaskLog(), getFailureExternalTaskLog(), fetchAndHandleHistoricExternalTaskLogs()
  • C8Client: insertJob() wiring existing JobMapper bean
  • EntitySkippedException: added HistoricExternalTaskLog constructor
  • C7Entity.of(HistoricExternalTaskLog): uses getTimestamp() as creation time
  • Rebased onto main: BaseMigrator replaced by HistoryEntityMigrator; HistoryMigrator now uses getMigrators() list with automatic retry loop; all migrators updated accordingly

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Test-only changes (no production code changes)

Testing Checklist

Black-Box Testing Requirements

  • Tests follow black-box testing approach: verify behavior through observable outputs (logs, C8 API queries, real-world skip scenarios)
  • Tests DO NOT access implementation details (DbClient, IdKeyMapper, ..impl.. packages except logging constants)
  • Architecture tests pass (ArchitectureTest validates these rules)

Test Coverage

  • Added tests for new functionality
  • Updated tests for modified functionality
  • All tests pass locally

HistoryExternalTaskTest covers:

  • Completed external task: verifies jobKey, type, worker, kind, elementId, processDefinitionId, tenantId, state=COMPLETED, endTime, partitionId
  • Failed external task: verifies state=FAILED, errorMessage, retries, hasFailedWithRetriesLeft=true

Architecture Compliance

Run architecture tests to ensure compliance:

mvn test -Dtest=ArchitectureTest

If architecture tests fail, refactor your tests to use:

  • LogCapturer for log assertions
  • camundaClient.new*SearchRequest() for C8 queries
  • Real-World skip scenarios (e.g., migrate children without parents)

Documentation

  • Updated TESTING_GUIDELINES.md if adding new test patterns
  • Added Javadoc comments for public APIs
  • Updated README if user-facing changes

Checklist

  • Code follows project style guidelines
  • Self-reviewed the code
  • Added comments for complex logic
  • No new compiler warnings
  • Dependent changes have been merged

Related Issues

Original prompt

This section details on the original issue you should resolve

<issue_title>(Optional) In Data Migrator History, external task logs are migrated</issue_title>
<issue_description>### User Story (Required on creation)

  • As a process engineer, I want to be migrate C7 external task logs history to as jobs in C8 so that I can maintain a complete audit trail for compliance purposes.

Functional Requirements (Required before implementation)

Technical Requirements (Required before implementation)

  • Plan: Migrate the external task logs per BPMN element
  • Create new mapping (HistoricExternalTaskLog (C7) -> JobDbModel (C8)) and add minimal test coverage
    • Create ExternalTaskMigrator, ExternalTaskTransformer
  • populate jobKey in Incident - skip incident if the job is not migrated
  • Populate jobKey, type, worker, state, kind, listenerEventType, retries, hasFailedWithRetriesLeft, errorMessage, deadline, endTime, processDefinitionId, processDefinitionKey, processInstanceKey, elementId, elementInstanceKey, tenantId, partitionId
  • Document limitations

Limitations of Scope

Hints

Links

Breakdown

Pull Requests

Dev2QA handover

  • Does this ticket need a QA test and the testing goals are not clear from the description? Add a Dev2QA handover comment</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Migrate C7 external task logs to C8 job history feat(history): Migrate C7 external task logs to C8 job history records Feb 19, 2026
Copilot AI requested a review from yanavasileva February 19, 2026 15:09
@HeleneW-dot
Copy link
Contributor

@copilot Can you rebase, resolve conflicts and adjust your changes to match the new migrator changes on main?

Copy link
Contributor Author

Copilot AI commented Feb 27, 2026

@copilot Can you rebase, resolve conflicts and adjust your changes to match the new migrator changes on main?

Done in commit a0ee35a. Rebased onto main and updated the changes to match the new HistoryEntityMigrator approach (replacing BaseMigrator):

  • Deleted BaseMigrator.java (replaced by HistoryEntityMigrator on main)
  • Updated ExternalTaskMigrator to extend HistoryEntityMigrator with the required fetchForMigrateHandler(), fetchForRetryHandler(), and getType() methods (replacing old migrateAll())
  • Wired ExternalTaskMigrator into HistoryMigrator.getMigrators() list (between variables and incidents)
  • Brought in all other main branch changes (all migrators now extend HistoryEntityMigrator, new retry loop in HistoryMigrator, HistoryMigrationInitialRetryLoopTest, etc.)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • artifacts.camunda.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 (dns block)
  • repository.sonatype.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

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.

(Optional) In Data Migrator History, external task logs are migrated

3 participants