Skip to content

chore(x2a): project name and short id used in target repo#2764

Merged
eloycoto merged 2 commits intoredhat-developer:mainfrom
elai-shalev:uuid-short
Apr 15, 2026
Merged

chore(x2a): project name and short id used in target repo#2764
eloycoto merged 2 commits intoredhat-developer:mainfrom
elai-shalev:uuid-short

Conversation

@elai-shalev
Copy link
Copy Markdown
Contributor

@elai-shalev elai-shalev commented Apr 14, 2026

instead of a long UUID representing a project in the target repo, now a combination of a sanitzed project name + UUID[0:6] chars will be used. This will enhance user experience

related to https://redhat.atlassian.net/browse/FLPATH-4020

@rhdh-qodo-merge
Copy link
Copy Markdown

Review Summary by Qodo

Use sanitized project name with short UUID for target repo directories

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Replace UUID-based directory naming with sanitized project name + short UUID
• Improve user experience with human-readable directory structure
• Update script logic to generate sanitized names from project names
• Simplify project abbreviation documentation
Diagram
flowchart LR
  A["Project Name + Full UUID"] -->|Sanitize & Shorten| B["Sanitized Name + Short UUID"]
  B -->|Format| C["Directory: my-chef-migration-0d52e6"]
  D["PROJECT_NAME"] -->|Transform| E["SANITIZED_NAME"]
  F["PROJECT_ID"] -->|Extract First 6| G["SHORT_UUID"]
  E -->|Combine| C
  G -->|Combine| C
Loading

Grey Divider

File Changes

1. workspaces/x2a/plugins/x2a-backend/src/services/types.ts 📝 Documentation +1/-1

Simplify projectAbbrev documentation

• Updated JSDoc comment for projectAbbrev field to remove implementation detail about directory
 naming
• Clarified that field is simply a project abbreviation without specifying its usage

workspaces/x2a/plugins/x2a-backend/src/services/types.ts


2. workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh ✨ Enhancement +5/-3

Implement sanitized name with short UUID directory naming

• Changed directory naming from ${PROJECT_ID}.${PROJECT_ABBREV} to
 ${SANITIZED_NAME}-${SHORT_UUID} format
• Added logic to sanitize project name by converting to lowercase and replacing special characters
 with hyphens
• Extract first 6 characters from PROJECT_ID as SHORT_UUID
• Updated git add command to use simplified ${PROJECT_DIR} variable
• Updated directory structure documentation to reflect new naming convention with example

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh


Grey Divider

Qodo Logo

@rhdh-qodo-merge
Copy link
Copy Markdown

rhdh-qodo-merge Bot commented Apr 14, 2026

Code Review by Qodo

🐞 Bugs (3)   📘 Rule violations (0)   📎 Requirement gaps (0)
🐞\ ≡ Correctness (1) ☼ Reliability (2)

Grey Divider


Action required

1. Project dir too long 🐞
Description
x2a-job-script.sh uses the full sanitized PROJECT_NAME in PROJECT_DIR without any length
bound, so long project names can exceed filesystem filename limits and cause mkdir/copy steps to
fail and abort the job.
Code

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[R238-243]

+SANITIZED_NAME=$(echo "${PROJECT_NAME}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')
+SHORT_UUID="${PROJECT_ID:0:6}"
+PROJECT_DIR="${SANITIZED_NAME}-${SHORT_UUID}"
PROJECT_PATH="${TARGET_BASE}/${PROJECT_DIR}"

# Create project directory in target
Evidence
The job script concatenates the entire sanitized PROJECT_NAME into PROJECT_DIR and then creates
${PROJECT_PATH} from it. The backend explicitly supports very long project names (test uses a
2000+ char name) and passes project.name through as PROJECT_NAME, while the OpenAPI schema
defines name as a required string with no max length; therefore an oversized PROJECT_DIR is
possible and will fail on common filesystems.

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-245]
workspaces/x2a/plugins/x2a-backend/src/services/JobResourceBuilder.ts[295-306]
workspaces/x2a/plugins/x2a-backend/src/services/JobResourceBuilder.test.ts[613-639]
workspaces/x2a/plugins/x2a-backend/src/schema/openapi.yaml[66-106]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`PROJECT_DIR` is derived from the full sanitized `PROJECT_NAME` with no maximum length. Very long project names (explicitly covered by existing tests) can produce a directory component that exceeds filesystem limits, causing the job script to fail during `mkdir -p`, `cp`, and later phases.

## Issue Context
- `PROJECT_NAME` comes directly from backend env injection.
- OpenAPI schema does not constrain `name` length.
- Existing tests demonstrate very long `projectName` values.

## Fix Focus Areas
- workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-245]

## Implementation notes
- After sanitization, truncate `SANITIZED_NAME` to a safe component length (e.g., 60–120 chars) before building `PROJECT_DIR`.
- Keep the short id suffix to preserve uniqueness/readability.
- Example approach:
 - `SANITIZED_NAME=${SANITIZED_NAME:0:80}` (or compute by bytes if needed)
 - Then `PROJECT_DIR="${SANITIZED_NAME}-${SHORT_UUID}"`

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Empty sanitized name breaks args 🐞
Description
If PROJECT_NAME sanitizes to an empty string, PROJECT_DIR becomes -<short_uuid> and is passed
to downstream commands (e.g., app.py publish-project), which can treat a leading - as an option
and fail argument parsing.
Code

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[R238-240]

+SANITIZED_NAME=$(echo "${PROJECT_NAME}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')
+SHORT_UUID="${PROJECT_ID:0:6}"
+PROJECT_DIR="${SANITIZED_NAME}-${SHORT_UUID}"
Evidence
The sanitization pipeline can yield an empty string (e.g., project name containing only
punctuation/whitespace) and there is no fallback before concatenating -${SHORT_UUID}. The
resulting PROJECT_DIR is used as a positional argument to app.py publish-project and as the
value for --project-id in publish-aap, so a leading dash can break CLI parsing and fail the
phase.

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-245]
workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[443-471]
workspaces/x2a/plugins/x2a-backend/src/services/JobResourceBuilder.ts[299-306]
workspaces/x2a/plugins/x2a-backend/src/schema/openapi.yaml[66-106]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`SANITIZED_NAME` may become empty after normalization. When that happens, `PROJECT_DIR` becomes `-${SHORT_UUID}` which can be interpreted as an option by downstream CLIs (and is generally a problematic identifier), causing publish steps (and potentially git operations) to fail.

## Issue Context
Sanitization strips all characters outside `[a-z0-9-]` and trims leading/trailing `-`. For names containing only invalid chars, the result is empty.

## Fix Focus Areas
- workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-245]
- workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[443-471]

## Implementation notes
- Add a fallback after sanitization, e.g.:
 - `if [ -z "${SANITIZED_NAME}" ]; then SANITIZED_NAME="project"; fi`
- Consider also hardening consumers:
 - `git add -- "${PROJECT_DIR}"`
 - If supported by the Python CLI, pass `--` before positional args.
- Also consider replacing `echo "${PROJECT_NAME}"` with `printf '%s' "${PROJECT_NAME}"` to avoid `echo` option quirks.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Short UUID collision risk 🐞
Description
PROJECT_DIR now uses only the first 6 hex characters of a UUID project id, which significantly
increases the probability that two different projects map to the same target directory and
overwrite/mix committed outputs.
Code

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[R239-240]

+SHORT_UUID="${PROJECT_ID:0:6}"
+PROJECT_DIR="${SANITIZED_NAME}-${SHORT_UUID}"
Evidence
Project IDs are generated using crypto.randomUUID(), so the first 6 characters represent only 24
bits (~16.7M possibilities). The prior naming scheme included the full UUID; truncating to 6 chars
reduces the uniqueness of the directory name and raises collision probability at scale.

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-242]
workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/projectOperations.ts[46-76]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Using only the first 6 characters of a UUID for directory naming increases the chance of collisions, which can cause different projects to share the same target repo folder and mix outputs.

## Issue Context
Project IDs are generated via `crypto.randomUUID()`; truncating to 6 chars leaves ~16.7M possibilities.

## Fix Focus Areas
- workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-242]
- workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/projectOperations.ts[46-76]

## Implementation notes
- Increase the suffix length (e.g., 8–12 chars) to reduce collision probability while keeping names reasonably short.
- Alternatively, keep the full UUID but consider shortening the *prefix* (project name) via truncation, so readability improves without sacrificing uniqueness.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@rhdh-gh-app
Copy link
Copy Markdown

rhdh-gh-app Bot commented Apr 14, 2026

Changed Packages

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

@elai-shalev elai-shalev marked this pull request as draft April 14, 2026 13:16
Comment on lines 238 to 243
SANITIZED_NAME=$(echo "${PROJECT_NAME}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')
SHORT_UUID="${PROJECT_ID:0:6}"
PROJECT_DIR="${SANITIZED_NAME}-${SHORT_UUID}"
PROJECT_PATH="${TARGET_BASE}/${PROJECT_DIR}"

# Create project directory in target
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Project dir too long 🐞 Bug ≡ Correctness

x2a-job-script.sh uses the full sanitized PROJECT_NAME in PROJECT_DIR without any length
bound, so long project names can exceed filesystem filename limits and cause mkdir/copy steps to
fail and abort the job.
Agent Prompt
## Issue description
`PROJECT_DIR` is derived from the full sanitized `PROJECT_NAME` with no maximum length. Very long project names (explicitly covered by existing tests) can produce a directory component that exceeds filesystem limits, causing the job script to fail during `mkdir -p`, `cp`, and later phases.

## Issue Context
- `PROJECT_NAME` comes directly from backend env injection.
- OpenAPI schema does not constrain `name` length.
- Existing tests demonstrate very long `projectName` values.

## Fix Focus Areas
- workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-245]

## Implementation notes
- After sanitization, truncate `SANITIZED_NAME` to a safe component length (e.g., 60–120 chars) before building `PROJECT_DIR`.
- Keep the short id suffix to preserve uniqueness/readability.
- Example approach:
  - `SANITIZED_NAME=${SANITIZED_NAME:0:80}` (or compute by bytes if needed)
  - Then `PROJECT_DIR="${SANITIZED_NAME}-${SHORT_UUID}"`

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +238 to +240
SANITIZED_NAME=$(echo "${PROJECT_NAME}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')
SHORT_UUID="${PROJECT_ID:0:6}"
PROJECT_DIR="${SANITIZED_NAME}-${SHORT_UUID}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Empty sanitized name breaks args 🐞 Bug ☼ Reliability

If PROJECT_NAME sanitizes to an empty string, PROJECT_DIR becomes -<short_uuid> and is passed
to downstream commands (e.g., app.py publish-project), which can treat a leading - as an option
and fail argument parsing.
Agent Prompt
## Issue description
`SANITIZED_NAME` may become empty after normalization. When that happens, `PROJECT_DIR` becomes `-${SHORT_UUID}` which can be interpreted as an option by downstream CLIs (and is generally a problematic identifier), causing publish steps (and potentially git operations) to fail.

## Issue Context
Sanitization strips all characters outside `[a-z0-9-]` and trims leading/trailing `-`. For names containing only invalid chars, the result is empty.

## Fix Focus Areas
- workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-245]
- workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[443-471]

## Implementation notes
- Add a fallback after sanitization, e.g.:
  - `if [ -z "${SANITIZED_NAME}" ]; then SANITIZED_NAME="project"; fi`
- Consider also hardening consumers:
  - `git add -- "${PROJECT_DIR}"`
  - If supported by the Python CLI, pass `--` before positional args.
- Also consider replacing `echo "${PROJECT_NAME}"` with `printf '%s' "${PROJECT_NAME}"` to avoid `echo` option quirks.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@mareklibra
Copy link
Copy Markdown
Member

By having that, we can completely remove the project abbreviation.

@elai-shalev
Copy link
Copy Markdown
Contributor Author

By having that, we can completely remove the project abbreviation.

Maybe we should? anyway that removal would be in a seperate pr

@elai-shalev elai-shalev marked this pull request as ready for review April 15, 2026 09:57
@rhdh-qodo-merge
Copy link
Copy Markdown

Review Summary by Qodo

Use sanitized project name with short UUID for target directories

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Replace UUID-based directory naming with sanitized project name + short UUID
• Improve user experience with readable directory structure in target repository
• Update script to generate sanitized project name from PROJECT_NAME variable
• Simplify git add command to use PROJECT_DIR variable consistently
Diagram
flowchart LR
  A["PROJECT_ID + PROJECT_NAME"] -->|Sanitize name| B["SANITIZED_NAME"]
  A -->|Extract first 6 chars| C["SHORT_UUID"]
  B -->|Combine| D["PROJECT_DIR: name-uuid"]
  D -->|Create directory| E["Target repository structure"]
Loading

Grey Divider

File Changes

1. workspaces/x2a/plugins/x2a-backend/src/services/types.ts 📝 Documentation +1/-1

Simplify projectAbbrev documentation

• Updated JSDoc comment for projectAbbrev field to remove implementation detail about directory
 naming
• Clarified that field is used for project abbreviation only

workspaces/x2a/plugins/x2a-backend/src/services/types.ts


2. workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh ✨ Enhancement +5/-3

Implement sanitized name with short UUID directory naming

• Changed directory naming from PROJECT_ID.PROJECT_ABBREV to SANITIZED_NAME-SHORT_UUID format
• Added sanitization logic to convert project name to lowercase and replace special characters with
 hyphens
• Extract first 6 characters from PROJECT_ID as SHORT_UUID
• Simplified git add command to use PROJECT_DIR variable instead of fallback pattern
• Updated directory structure documentation comments to reflect new naming convention

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh


Grey Divider

Qodo Logo

@rhdh-qodo-merge
Copy link
Copy Markdown

rhdh-qodo-merge Bot commented Apr 15, 2026

Code Review by Qodo

🐞 Bugs (3)   📘 Rule violations (0)   📎 Requirement gaps (0)
🐞\ ≡ Correctness (1) ☼ Reliability (2)

Grey Divider


Action required

1. Empty sanitized name breaks args 🐞
Description
If PROJECT_NAME sanitizes to an empty string, PROJECT_DIR becomes -<short_uuid> and is passed
to downstream commands (e.g., app.py publish-project), which can treat a leading - as an option
and fail argument parsing.
Code

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[R238-240]

+SANITIZED_NAME=$(echo "${PROJECT_NAME}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')
+SHORT_UUID="${PROJECT_ID:0:6}"
+PROJECT_DIR="${SANITIZED_NAME}-${SHORT_UUID}"
Evidence
The sanitization pipeline can yield an empty string (e.g., project name containing only
punctuation/whitespace) and there is no fallback before concatenating -${SHORT_UUID}. The
resulting PROJECT_DIR is used as a positional argument to app.py publish-project and as the
value for --project-id in publish-aap, so a leading dash can break CLI parsing and fail the
phase.

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-245]
workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[443-471]
workspaces/x2a/plugins/x2a-backend/src/services/JobResourceBuilder.ts[299-306]
workspaces/x2a/plugins/x2a-backend/src/schema/openapi.yaml[66-106]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`SANITIZED_NAME` may become empty after normalization. When that happens, `PROJECT_DIR` becomes `-${SHORT_UUID}` which can be interpreted as an option by downstream CLIs (and is generally a problematic identifier), causing publish steps (and potentially git operations) to fail.

## Issue Context
Sanitization strips all characters outside `[a-z0-9-]` and trims leading/trailing `-`. For names containing only invalid chars, the result is empty.

## Fix Focus Areas
- workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-245]
- workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[443-471]

## Implementation notes
- Add a fallback after sanitization, e.g.:
 - `if [ -z "${SANITIZED_NAME}" ]; then SANITIZED_NAME="project"; fi`
- Consider also hardening consumers:
 - `git add -- "${PROJECT_DIR}"`
 - If supported by the Python CLI, pass `--` before positional args.
- Also consider replacing `echo "${PROJECT_NAME}"` with `printf '%s' "${PROJECT_NAME}"` to avoid `echo` option quirks.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Project dir too long 🐞
Description
x2a-job-script.sh uses the full sanitized PROJECT_NAME in PROJECT_DIR without any length
bound, so long project names can exceed filesystem filename limits and cause mkdir/copy steps to
fail and abort the job.
Code

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[R238-243]

+SANITIZED_NAME=$(echo "${PROJECT_NAME}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')
+SHORT_UUID="${PROJECT_ID:0:6}"
+PROJECT_DIR="${SANITIZED_NAME}-${SHORT_UUID}"
PROJECT_PATH="${TARGET_BASE}/${PROJECT_DIR}"

# Create project directory in target
Evidence
The job script concatenates the entire sanitized PROJECT_NAME into PROJECT_DIR and then creates
${PROJECT_PATH} from it. The backend explicitly supports very long project names (test uses a
2000+ char name) and passes project.name through as PROJECT_NAME, while the OpenAPI schema
defines name as a required string with no max length; therefore an oversized PROJECT_DIR is
possible and will fail on common filesystems.

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-245]
workspaces/x2a/plugins/x2a-backend/src/services/JobResourceBuilder.ts[295-306]
workspaces/x2a/plugins/x2a-backend/src/services/JobResourceBuilder.test.ts[613-639]
workspaces/x2a/plugins/x2a-backend/src/schema/openapi.yaml[66-106]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`PROJECT_DIR` is derived from the full sanitized `PROJECT_NAME` with no maximum length. Very long project names (explicitly covered by existing tests) can produce a directory component that exceeds filesystem limits, causing the job script to fail during `mkdir -p`, `cp`, and later phases.

## Issue Context
- `PROJECT_NAME` comes directly from backend env injection.
- OpenAPI schema does not constrain `name` length.
- Existing tests demonstrate very long `projectName` values.

## Fix Focus Areas
- workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-245]

## Implementation notes
- After sanitization, truncate `SANITIZED_NAME` to a safe component length (e.g., 60–120 chars) before building `PROJECT_DIR`.
- Keep the short id suffix to preserve uniqueness/readability.
- Example approach:
 - `SANITIZED_NAME=${SANITIZED_NAME:0:80}` (or compute by bytes if needed)
 - Then `PROJECT_DIR="${SANITIZED_NAME}-${SHORT_UUID}"`

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Short UUID collision risk 🐞
Description
PROJECT_DIR now uses only the first 6 hex characters of a UUID project id, which significantly
increases the probability that two different projects map to the same target directory and
overwrite/mix committed outputs.
Code

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[R239-240]

+SHORT_UUID="${PROJECT_ID:0:6}"
+PROJECT_DIR="${SANITIZED_NAME}-${SHORT_UUID}"
Evidence
Project IDs are generated using crypto.randomUUID(), so the first 6 characters represent only 24
bits (~16.7M possibilities). The prior naming scheme included the full UUID; truncating to 6 chars
reduces the uniqueness of the directory name and raises collision probability at scale.

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-242]
workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/projectOperations.ts[46-76]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Using only the first 6 characters of a UUID for directory naming increases the chance of collisions, which can cause different projects to share the same target repo folder and mix outputs.

## Issue Context
Project IDs are generated via `crypto.randomUUID()`; truncating to 6 chars leaves ~16.7M possibilities.

## Fix Focus Areas
- workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[235-242]
- workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/projectOperations.ts[46-76]

## Implementation notes
- Increase the suffix length (e.g., 8–12 chars) to reduce collision probability while keeping names reasonably short.
- Alternatively, keep the full UUID but consider shortening the *prefix* (project name) via truncation, so readability improves without sacrificing uniqueness.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@mareklibra
Copy link
Copy Markdown
Member

By having that, we can completely remove the project abbreviation.

Maybe we should? anyway that removal would be in a seperate pr

The abbreviation and changes in this PR share the use-case. There is no additional use for it when we merge this.
It's ok to do the removal in a follow-up.

TARGET_BASE="/workspace/target"
SOURCE_BASE="/workspace/source"
PROJECT_DIR="${PROJECT_ID}.${PROJECT_ABBREV}"
SANITIZED_NAME=$(echo "${PROJECT_NAME}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SANITIZED_NAME can become very long, what about limiting it to 64 characters or similar? Taking first and last part of the project name? Or truncate at least.

Using a default for empty project name? This should not happen thanks to our other checks, but... If this happens, the name will start with a dash which should be avoided in any case (like project name starts with "-n ; echo I am malicious".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good points, let me apply some guards

Copy link
Copy Markdown
Member

@mareklibra mareklibra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a changeset?

@@ -47,7 +47,7 @@ export interface JobCreateParams {
projectId: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about if we create a ValueObject called Project:

https://khalilstemmler.com/articles/typescript-value-object/

And from here, we can say:

Project.name () -> self.projectName+self.abbre+self.id.slice(0, 5)?
Project.id() -> self.id
Project.base_name: self.projectName+sefl.abbr

And we have all in there, so we can skip the bash changes? and we can do all sanitization here?

@sonarqubecloud
Copy link
Copy Markdown

@elai-shalev
Copy link
Copy Markdown
Contributor Author

elai-shalev commented Apr 15, 2026

@eloycoto @mareklibra Thank you for the review
I've implemented Eloy's suggestion - it does seem much cleaner and maintainable.
also added changeset

@eloycoto eloycoto merged commit 1f6770f into redhat-developer:main Apr 15, 2026
10 checks passed
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