Skip to content

Comments

Fix language parameter handling in news-article-generator workflow#172

Merged
pethers merged 5 commits intomainfrom
copilot/analyze-language-options-usage
Feb 14, 2026
Merged

Fix language parameter handling in news-article-generator workflow#172
pethers merged 5 commits intomainfrom
copilot/analyze-language-options-usage

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

DevOps Fix: Language Parameter Handling - Review Comments Addressed

Changes Made

1. ✅ Fixed Preset Expansion with Whitespace (Comment 2807597523)

File: scripts/generate-news-enhanced.js

  • Issue: Preset expansion checked LANGUAGE_PRESETS[languagesInput] before trimming, so "nordic " (with trailing space) wouldn't match
  • Fix: Added .trim().toLowerCase() before preset lookup on line 50
  • Result: Now handles "nordic ", " NORDIC ", "Nordic" correctly

2. ✅ Fixed Bash Case Statement Matching (Comment 2807597529)

File: .github/workflows/news-article-generator.md

  • Issue: Languages preset case statement used raw LANGUAGES_INPUT without trimming
  • Fix: Added LANGUAGES_INPUT=$(echo "$LANGUAGES_INPUT" | xargs) before case statement (line 280)
  • Result: Presets now match even with leading/trailing whitespace

3. ✅ Added Validation Gate (Comment 2807597531)

File: .github/workflows/news-article-generator.md

  • Issue: Language validation printed errors but never failed the run
  • Fix: Added tracking of missing languages and exit 1 when any are missing (lines 521-535)
  • Result: Workflow now fails fast if requested languages aren't generated
# Track any languages that are missing articles
missing_langs=()

# ... validation loop ...

# Fail the workflow if any requested languages are missing articles
if [ "${#missing_langs[@]}" -ne 0 ]; then
  echo "❌ Validation failed: No articles generated for: ${missing_langs[*]}"
  exit 1
else
  echo "✅ Validation passed: Articles generated for all requested languages."
fi

4. ✅ Fixed File Existence Check (Comment 2807597535)

File: docs/LANGUAGE_OPTIONS_TESTING.md

  • Issue: news/$(ls -t news/*-${lang}.html ...) produced news/news/... path
  • Fix: Simplified to ls -t news/*-"$lang".html 1>/dev/null 2>&1 (line 262)
  • Result: RTL attribute check now works correctly

5. ✅ Bonus: Fixed Same Issues in Backport Script

File: scripts/generate-news-backport.js

  • Applied same whitespace handling fixes
  • Ensures consistency across all news generation scripts

Testing Results

Test 1: Preset with Trailing Space

node scripts/generate-news-enhanced.js --languages="nordic " --dry-run
# ✅ Output: Languages: en, sv, da, no, fi

Test 2: Preset with Spaces and Uppercase

node scripts/generate-news-enhanced.js --languages=" NORDIC " --dry-run
# ✅ Output: Languages: en, sv, da, no, fi

Test 3: Validation Gate

The validation now tracks missing languages and exits with error code 1, preventing incomplete article generation from being accepted.

Files Changed

File Changes Lines
scripts/generate-news-enhanced.js Trim+lowercase before preset lookup 50
scripts/generate-news-backport.js Same fix for consistency 57-61
.github/workflows/news-article-generator.md Trim input + validation gate 280, 521-535
docs/LANGUAGE_OPTIONS_TESTING.md Fix file existence check 262

Next Steps

All review comments addressed. Ready for re-review and merge.


Commit: Applying all 4 PR review comments


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Analyze language options in workflows and code Fix language parameter handling in news-article-generator workflow Feb 14, 2026
Copilot AI requested a review from pethers February 14, 2026 15:31
@github-actions
Copy link
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Contributor

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

Improves multi-language generation reliability for the news article generator by fixing whitespace handling in CLI parsing and updating the agent workflow instructions/docs to consistently invoke the existing generation script with expanded language presets.

Changes:

  • Trim whitespace when parsing --types and --languages in scripts/generate-news-enhanced.js.
  • Update .github/workflows/news-article-generator.md agent instructions to expand language presets and run generate-news-enhanced.js, plus add a language coverage validation step.
  • Add a comprehensive manual testing guide for language options under docs/.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
scripts/generate-news-enhanced.js Trims CLI inputs for article types and languages to correctly handle lists like "no, da, fi".
.github/workflows/news-article-generator.md Adds explicit bash examples for expanding presets and calling the generation script, plus language coverage validation guidance.
docs/LANGUAGE_OPTIONS_TESTING.md Adds a manual test/validation playbook for language presets, whitespace edge cases, and RTL verification.

Comment on lines +50 to +57
}

const languages = languagesInput.split(',').filter(l => ALL_LANGUAGES.includes(l.trim()));
const languages = languagesInput.split(',').map(l => l.trim()).filter(l => ALL_LANGUAGES.includes(l));
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The preset expansion checks LANGUAGE_PRESETS[languagesInput] before trimming, so inputs like --languages="nordic " (or newline/space from workflow inputs) won’t expand and will later be filtered to zero valid languages. Normalize languagesInput (trim and ideally lowercase) before the preset lookup so whitespace doesn’t break presets.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 047eb4c. Added .trim().toLowerCase() to normalize languagesInput before preset lookup. Now handles "nordic ", " NORDIC ", and mixed case correctly.

Comment on lines 277 to 288
LANGUAGES_INPUT="${{ github.event.inputs.languages }}"
if [ -z "$LANGUAGES_INPUT" ]; then
LANGUAGES_INPUT="en,sv"
fi

# Expand language presets
case "$LANGUAGES_INPUT" in
"nordic")
LANG_ARG="en,sv,da,no,fi"
echo "🌍 Expanding 'nordic' to: $LANG_ARG"
;;
"eu-core")
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The languages preset case statement uses the raw LANGUAGES_INPUT. If the input contains leading/trailing whitespace, presets like nordic/eu-core won’t match and the script may fail later. Trim/normalize LANGUAGES_INPUT before the case so preset handling is robust.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 047eb4c. Added LANGUAGES_INPUT=$(echo "$LANGUAGES_INPUT" | xargs) before the case statement to trim whitespace. Presets now match reliably.

Comment on lines 520 to 532
for lang in "${LANG_ARRAY[@]}"; do
lang_trimmed=$(echo "$lang" | xargs) # Trim whitespace

# Count articles for this language
count=$(find news -name "*-${lang_trimmed}.html" -type f -mmin -10 | wc -l)

if [ $count -gt 0 ]; then
echo " ✅ $lang_trimmed: $count articles generated"
else
echo " ❌ $lang_trimmed: No articles found (expected at least 1)"
fi
done

Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

This validation loop prints an error when a requested language has no generated articles, but it never fails the run. If this is meant to be a real validation gate, track missing languages and exit 1 when any are missing so the agent/workflow can’t proceed with partial output.

Suggested change
for lang in "${LANG_ARRAY[@]}"; do
lang_trimmed=$(echo "$lang" | xargs) # Trim whitespace
# Count articles for this language
count=$(find news -name "*-${lang_trimmed}.html" -type f -mmin -10 | wc -l)
if [ $count -gt 0 ]; then
echo " ✅ $lang_trimmed: $count articles generated"
else
echo " ❌ $lang_trimmed: No articles found (expected at least 1)"
fi
done
# Track any languages that are missing articles
missing_langs=()
for lang in "${LANG_ARRAY[@]}"; do
lang_trimmed=$(echo "$lang" | xargs) # Trim whitespace
# Count articles for this language
count=$(find news -name "*-${lang_trimmed}.html" -type f -mmin -10 | wc -l)
if [ "$count" -gt 0 ]; then
echo " ✅ $lang_trimmed: $count articles generated"
else
echo " ❌ $lang_trimmed: No articles found (expected at least 1)"
missing_langs+=("$lang_trimmed")
fi
done
# Fail the workflow if any requested languages are missing articles
if [ "${#missing_langs[@]}" -ne 0 ]; then
echo "❌ Validation failed: No articles generated for the following requested languages: ${missing_langs[*]}"
exit 1
else
echo "✅ Validation passed: Articles generated for all requested languages."
fi

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 047eb4c. Implemented suggestion exactly as provided - now tracks missing_langs array and exits with exit 1 when any requested languages have zero articles. This creates a proper validation gate.

Comment on lines 262 to 263
if [ -f "news/$(ls -t news/*-${lang}.html 2>/dev/null | head -1)" ]; then
if grep -q 'dir="rtl"' "news/"*-${lang}.html; then
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The file existence check is incorrect: ls -t news/*-${lang}.html already returns paths that include news/, so wrapping it with news/$(...) produces news/news/... and the -f test will fail even when files exist. Remove the extra news/ prefix or restructure the existence check.

Suggested change
if [ -f "news/$(ls -t news/*-${lang}.html 2>/dev/null | head -1)" ]; then
if grep -q 'dir="rtl"' "news/"*-${lang}.html; then
if ls -t news/*-"$lang".html 1>/dev/null 2>&1; then
if grep -q 'dir="rtl"' news/*-"$lang".html; then

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 047eb4c. Simplified to ls -t news/*-"$lang".html 1>/dev/null 2>&1 to avoid the double news/ prefix. File existence check now works correctly.

@pethers
Copy link
Member

pethers commented Feb 14, 2026

@copilot apply changes based on the comments in this thread

Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

@copilot apply changes based on the comments in this thread

All 4 review comments addressed in commit 047eb4c:

  1. ✅ Normalized input before preset expansion (scripts)
  2. ✅ Trimmed input before case statement (workflow)
  3. ✅ Added validation gate with exit 1 on missing languages
  4. ✅ Fixed file existence check path construction

Bonus: Also fixed same issues in generate-news-backport.js for consistency.

@github-actions
Copy link
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Contributor

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@pethers pethers marked this pull request as ready for review February 14, 2026 16:51
@pethers pethers merged commit 6caaa4d into main Feb 14, 2026
21 checks passed
@pethers pethers deleted the copilot/analyze-language-options-usage branch February 14, 2026 16:52
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.

2 participants