Implement verbose error feedback across all scripts

- Enhanced die() function with environment context and stack trace
- Added detailed error output with line numbers and file paths
- Improved check_dependencies with installation guides
- Enhanced PHP syntax validation with full error details
- Added verbose error messages to manifest, tabs, and paths validations
- Updated validate_all to show error summaries (full output in verbose mode)
- Updated smoke_test with detailed PHP error reporting
- Updated ENTERPRISE.md with verbose error examples
- All error messages now provide actionable troubleshooting steps

Co-authored-by: jmiller-moko <230051081+jmiller-moko@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-03 23:16:45 +00:00
parent 0341131f18
commit aaa6560d74
8 changed files with 228 additions and 44 deletions

View File

@@ -92,7 +92,23 @@ if [ "${#manifest_candidates[@]}" -eq 0 ]; then
fi
if [ "${#manifest_candidates[@]}" -eq 0 ]; then
fail "No Joomla manifest XML found under ${SRC_DIR}"
{
echo "ERROR: No Joomla manifest XML found under ${SRC_DIR}" >&2
echo "" >&2
echo "Expected manifest file patterns:" >&2
echo " - Template: ${SRC_DIR}/templateDetails.xml" >&2
echo " - Package: ${SRC_DIR}/**/pkg_*.xml" >&2
echo " - Component: ${SRC_DIR}/**/com_*.xml" >&2
echo " - Module: ${SRC_DIR}/**/mod_*.xml" >&2
echo " - Plugin: ${SRC_DIR}/**/plg_*.xml" >&2
echo "" >&2
echo "Troubleshooting:" >&2
echo " 1. Verify the source directory exists: ls -la ${SRC_DIR}" >&2
echo " 2. Check for XML files: find ${SRC_DIR} -name '*.xml'" >&2
echo " 3. Ensure manifest contains <extension> root element" >&2
echo "" >&2
} >&2
fail "No manifest found"
fi
# De-duplicate while preserving order.
@@ -115,11 +131,21 @@ manifest_candidates=("${unique_candidates[@]}")
if [ "${#manifest_candidates[@]}" -gt 1 ]; then
{
log "ERROR: Multiple manifest candidates detected. Resolve to exactly one primary manifest." >&2
log "Candidates:" >&2
log "" >&2
log "Found ${#manifest_candidates[@]} candidates:" >&2
for c in "${manifest_candidates[@]}"; do
log "- ${c}" >&2
log " - ${c}" >&2
done
}
log "" >&2
log "Resolution options:" >&2
log " 1. Remove redundant manifest files" >&2
log " 2. Move extra manifests outside ${SRC_DIR}" >&2
log " 3. Rename non-primary manifests to not match patterns (templateDetails.xml, pkg_*.xml, etc.)" >&2
log "" >&2
log "For package extensions, only the top-level package manifest should be in ${SRC_DIR}." >&2
log "Child extension manifests should be in subdirectories." >&2
log "" >&2
} >&2
exit 1
fi

View File

@@ -39,21 +39,39 @@ set -euo pipefail
# Uses git ls-files -z and searches file contents for a literal backslash.
hits=()
hit_lines=()
while IFS= read -r -d '' f; do
# Skip common binary files by mime-type
if file --brief --mime-type "$f" | grep -qE '^(application|audio|image|video)/'; then
continue
fi
if grep -F $'\\' -- "$f" >/dev/null 2>&1; then
# Find lines with backslashes and collect details
if backslash_lines=$(grep -n -F $'\\' -- "$f" 2>/dev/null); then
hits+=("$f")
hit_lines+=("$backslash_lines")
fi
done < <(git ls-files -z)
if [ "${#hits[@]}" -gt 0 ]; then
echo "ERROR: windows_path_literal_detected"
for h in "${hits[@]}"; do
echo " - ${h}"
echo "ERROR: Windows-style path literals detected" >&2
echo "" >&2
echo "Found backslashes in ${#hits[@]} file(s):" >&2
for i in "${!hits[@]}"; do
echo "" >&2
echo " File: ${hits[$i]}" >&2
echo " Lines with backslashes:" >&2
echo "${hit_lines[$i]}" | head -5 | sed 's/^/ /' >&2
if [ "$(echo "${hit_lines[$i]}" | wc -l)" -gt 5 ]; then
echo " ... and $(($(echo "${hit_lines[$i]}" | wc -l) - 5)) more" >&2
fi
done
echo "" >&2
echo "To fix:" >&2
echo " 1. Run: ./scripts/fix/paths.sh" >&2
echo " 2. Or manually replace backslashes (\\) with forward slashes (/)" >&2
echo " 3. Ensure paths use POSIX separators for cross-platform compatibility" >&2
echo "" >&2
exit 2
fi

View File

@@ -59,25 +59,44 @@ fi
failed=0
checked=0
failed_files=()
failed_errors=()
while IFS= read -r -d '' f; do
checked=$((checked+1))
# Capture actual error output
error_output=""
# Use timeout if available to prevent hangs
if command -v timeout >/dev/null 2>&1; then
if ! timeout "${TIMEOUT}" php -l "$f" >/dev/null 2>&1; then
if ! error_output=$(timeout "${TIMEOUT}" php -l "$f" 2>&1); then
failed=1
failed_files+=("$f")
failed_errors+=("$error_output")
fi
else
if ! php -l "$f" >/dev/null 2>&1; then
if ! error_output=$(php -l "$f" 2>&1); then
failed=1
failed_files+=("$f")
failed_errors+=("$error_output")
fi
fi
done < <(find "${SRC_DIR}" -type f -name '*.php' -print0)
if [ "${failed}" -ne 0 ]; then
echo "ERROR: PHP syntax validation failed" >&2
echo "Files checked: ${checked}" >&2
echo "Files with errors: ${#failed_files[@]}" >&2
echo "" >&2
echo "Failed files and errors:" >&2
for i in "${!failed_files[@]}"; do
echo " File: ${failed_files[$i]}" >&2
echo " Error: ${failed_errors[$i]}" >&2
echo "" >&2
done
echo "" >&2
echo "To fix: Review and correct the syntax errors in the files listed above." >&2
echo "Run 'php -l <filename>' on individual files for detailed error messages." >&2
{
printf '{"status":"fail","error":"php_lint_failed","files_checked":%s,"failed_count":%s,"failed_files":[' "${checked}" "${#failed_files[@]}"
for i in "${!failed_files[@]}"; do

View File

@@ -48,15 +48,39 @@ if [ -z "${files}" ]; then
fi
bad=0
bad_files=()
bad_lines=()
while IFS= read -r f; do
if grep -n $'\t' -- "$f" >/dev/null 2>&1; then
echo "TAB found in $f"
# Find lines with tabs and store them
if tab_lines=$(grep -n $'\t' -- "$f" 2>/dev/null); then
echo "TAB found in $f" >&2
echo " Lines with tabs:" >&2
echo "$tab_lines" | head -5 | sed 's/^/ /' >&2
if [ "$(echo "$tab_lines" | wc -l)" -gt 5 ]; then
echo " ... and $(($(echo "$tab_lines" | wc -l) - 5)) more" >&2
fi
echo "" >&2
bad=1
bad_files+=("$f")
fi
done <<< "${files}"
if [ "${bad}" -ne 0 ]; then
echo "" >&2
echo "ERROR: Tabs found in repository files" >&2
echo "" >&2
echo "YAML specification forbids tab characters." >&2
echo "Found tabs in ${#bad_files[@]} file(s):" >&2
for f in "${bad_files[@]}"; do
echo " - $f" >&2
done
echo "" >&2
echo "To fix:" >&2
echo " 1. Run: ./scripts/fix/tabs.sh" >&2
echo " 2. Or manually replace tabs with spaces in your editor" >&2
echo " 3. Configure your editor to use spaces (not tabs) for YAML files" >&2
echo "" >&2
exit 2
fi