Skip to content

Comments

feat(x2a): Track and display commit ID per job#2364

Draft
elai-shalev wants to merge 2 commits intoredhat-developer:mainfrom
elai-shalev:commit-id-tracking
Draft

feat(x2a): Track and display commit ID per job#2364
elai-shalev wants to merge 2 commits intoredhat-developer:mainfrom
elai-shalev:commit-id-tracking

Conversation

@elai-shalev
Copy link
Contributor

@elai-shalev elai-shalev commented Feb 19, 2026

User description

This PR will introduce tracking and displaying of cimmit id per job, to keep track for the "latest commit on the target repository created by the x2a job"

  • Each K8s job (analyze, migrate, publish) pushes to the target repo. This PR captures the git commit SHA produced by each job and displays it on the Module
    page so users can trace exactly which commit a phase produced.
  • Adds commit_id column to the jobs table, extends the OpenAPI spec and collectArtifacts endpoint to accept commitId, and updates the job shell script to
    capture the SHA via git rev-parse HEAD after a successful push.
  • The frontend Module page now shows a "Last Commit ID" field per phase tab.

JIRA: https://issues.redhat.com/browse/FLPATH-3297


PR Type

Enhancement


Description

  • Add commit_id column to jobs table and track git commit SHA per job

  • Extend OpenAPI spec and collectArtifacts endpoint to accept and store commitId

  • Update job shell script to capture commit SHA via git rev-parse HEAD after push

  • Display "Last Commit ID" field in Module page phase tabs with multi-language support


File Walkthrough

Relevant files
Database schema
1 files
2025012401_create_jobs_table.ts
Add commit_id column to jobs table                                             
+1/-0     
Enhancement
6 files
collectArtifacts.ts
Add commitId to request schema and interface                         
+3/-0     
index.ts
Add commitId parameter to updateJob method                             
+1/-0     
jobOperations.ts
Include commit_id in job queries and updates                         
+7/-0     
mappers.ts
Map commit_id from database row to Job object                       
+1/-0     
x2a-job-script.sh
Capture commit SHA after successful git push                         
+7/-0     
PhasesCard.tsx
Display Last Commit ID in phase details                                   
+6/-0     
Code generation
5 files
Job.model.ts
Add commitId field to Job model                                                   
+4/-0     
ProjectsProjectIdCollectArtifactsPostRequest.model.ts
Add commitId to request model                                                       
+4/-0     
router.ts
Update OpenAPI spec with commitId field                                   
+8/-0     
Job.model.ts
Add commitId field to client Job model                                     
+4/-0     
ProjectsProjectIdCollectArtifactsPostRequest.model.ts
Add commitId to client request model                                         
+4/-0     
Documentation
8 files
de.ts
Add German translation for Last Commit ID                               
+1/-0     
es.ts
Add Spanish translation for Last Commit ID                             
+1/-0     
fr.ts
Add French translation for Last Commit ID                               
+1/-0     
it.ts
Add Italian translation for Last Commit ID                             
+1/-0     
ref.ts
Add English reference translation for commitId                     
+1/-0     
openapi.yaml
Add commitId to OpenAPI schema definitions                             
+6/-0     
report.api.md
Update API documentation with commitId field                         
+2/-0     
report.api.md
Update API documentation with commitId translation             
+1/-0     

@elai-shalev elai-shalev marked this pull request as draft February 19, 2026 14:22
@rhdh-gh-app
Copy link

rhdh-gh-app bot commented Feb 19, 2026

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @red-hat-developer-hub/backstage-plugin-x2a-backend
  • @red-hat-developer-hub/backstage-plugin-x2a-common
  • @red-hat-developer-hub/backstage-plugin-x2a

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-x2a-backend workspaces/x2a/plugins/x2a-backend none v1.0.1
@red-hat-developer-hub/backstage-plugin-x2a-common workspaces/x2a/plugins/x2a-common none v1.0.1
@red-hat-developer-hub/backstage-plugin-x2a workspaces/x2a/plugins/x2a none v1.0.1

@rhdh-qodo-merge
Copy link

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
Unvalidated input storage

Description: commitId is accepted as an arbitrary optional string and persisted to the jobs.commit_id
column without format/length validation, which could enable stored untrusted data issues
(e.g., excessively large payloads for DB/log bloat, or injection/XSS risks if any
downstream consumer renders commitId without escaping/sanitization); consider constraining
it to a Git SHA pattern (e.g., ^[0-9a-f]{7,40}$) and enforcing a sane max length at both
API and DB levels.
collectArtifacts.ts [58-170]

Referred Code
const collectArtifactsRequestSchema = z.object({
  status: z.enum(['success', 'error']),
  errorDetails: z.string().optional(),
  jobId: z.string().uuid('Job ID must be a valid UUID'),
  artifacts: z.array(artifactSchema).optional(),
  telemetry: telemetrySchema.optional(),
  commitId: z.string().optional(),
});

export interface CollectArtifactsRequestBody {
  status: 'success' | 'error';
  errorDetails?: string;
  jobId: string;
  artifacts?: Artifact[];
  telemetry?: Telemetry;
  commitId?: string;
}

export function registerCollectArtifactsRoutes(
  router: express.Router,
  deps: RouterDeps,


 ... (clipped 92 lines)
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@sonarqubecloud
Copy link

@rhdh-qodo-merge
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Capture commit ID before pushing

In x2a-job-script.sh, capture the git commit hash before the git push command
and clear it if the push fails to ensure the correct commit ID is always used.

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh [95-100]

+COMMIT_ID=$(git rev-parse HEAD 2>/dev/null || echo "")
 if ! git push origin "${TARGET_REPO_BRANCH}"; then
   PUSH_FAILED="Failed to push to ${TARGET_REPO_URL} branch ${TARGET_REPO_BRANCH}"
   echo "ERROR: ${PUSH_FAILED}"
-else
-  COMMIT_ID=$(git rev-parse HEAD 2>/dev/null || echo "")
+  COMMIT_ID=""
 fi
  • Apply / Chat
Suggestion importance[1-10]: 3

__

Why: The suggestion correctly identifies a potential for improvement in the script's logic, although the race condition described is unlikely. The proposed change to capture the COMMIT_ID before the push and clear it on failure is a slightly cleaner and more robust pattern.

Low
  • More

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant