Skip to content

Workspace Lab Exercise 1 formatting and script fixes#239

Merged
jeremylongshore merged 6 commits intojeremylongshore:mainfrom
jleonelion:main
Jan 4, 2026
Merged

Workspace Lab Exercise 1 formatting and script fixes#239
jeremylongshore merged 6 commits intojeremylongshore:mainfrom
jleonelion:main

Conversation

@jleonelion
Copy link
Copy Markdown
Contributor

@jleonelion jleonelion commented Jan 3, 2026

Pull Request

Type of Change

  • 🔌 New plugin submission
  • ⬆️ Plugin update/enhancement
  • 📚 Documentation improvement
  • 🐛 Bug fix
  • 🏗️ Infrastructure/CI improvement
  • 🎨 Marketplace website update
  • 🔧 Configuration change
  • 🧪 Tests added/updated
  • 🔐 Security fix
  • 🚀 Performance improvement
  • ♻️ Refactoring
  • 🌐 Translation/i18n
  • 🗑️ Deprecation/removal
  • 📦 Dependency update
  • 🎯 Other (please describe)

Description

Summary:

  • fix formatting of exercise 1 markdown file to render as expected
  • add debugging and fix variable scoping problem in the analyze_field_utilitzation.sh script

Motivation:

  • copy/paste of code blocks from markdown as not as intended
  • script was failing to execute because the array variables in the while loop where scoped to subshell (so added values where not appearing when these variables where examined outside the loop)

Related Issues:

Security

  • Related alerts: GHSA-/CVE-
  • Impact assessment: Low

Checklist

For All PRs

  • I have read the CONTRIBUTING.md guidelines
  • My code follows the project's style and conventions
  • I have performed a self-review of my code
  • I have commented my code where necessary
  • My changes generate no new warnings or errors
  • Documentation has been updated (if applicable)
  • CodeQL passes; no new code scanning alerts
  • No high/critical Dependabot alerts introduced

For Documentation Changes

  • Spelling and grammar checked
  • Code examples tested and working
  • Links verified and not broken
  • Screenshots/diagrams updated (if applicable)
  • Version references updated

Testing Evidence

Test Environment:

  • OS: MacOS
  • Claude Code Version: N/A
  • Python Version (if applicable): N/A
  • Node Version (if applicable): N/A

Test Results:

Edge Cases Tested:

  • Works with minimal configuration
  • Handles errors gracefully
  • Works across different platforms (macOS, Linux, Windows)
  • Performance is acceptable for large inputs
  • Security considerations addressed

Additional Notes

Reviewer Checklist (for maintainers)

  • Code quality meets standards
  • Tests pass (CI/CD green)
  • Security review completed
  • Documentation is clear and complete
  • Breaking changes documented
  • Version bumped appropriately
  • CHANGELOG.md updated
  • Ready to merge

By submitting this PR, I confirm:

  • I have the right to submit this code under the project's license
  • I understand my contributions will be publicly available
  • I agree to the project's Code of Conduct (if exists)

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @jleonelion, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the clarity and functionality of a workspace lab exercise. It addresses rendering inconsistencies in the exercise's Markdown documentation, making it easier for users to follow instructions and copy code. Concurrently, it fixes a significant bug in an associated shell script that prevented correct data aggregation due to variable scoping, ensuring the script now executes reliably and produces accurate results.

Highlights

  • Documentation Formatting Fixes: Corrected Markdown formatting in exercise-1-run-workflow.md to ensure code blocks, tables, and list items render as expected, improving readability and usability of the lab exercise.
  • Script Variable Scoping Fix: Resolved a critical variable scoping issue in the analyze_field_utilization.sh script by changing the while loop's input method from a pipe to process substitution, ensuring that array variables (UNUSED_FIELDS, LOW_UTIL_FIELDS, HIGH_UTIL_FIELDS) are correctly populated and accessible outside the loop.
  • Script Debugging and Robustness: Added extensive debugging log statements to analyze_field_utilization.sh for better visibility into field processing and categorization. Also improved the robustness of JSON generation by explicitly handling empty arrays, preventing potential errors.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces formatting fixes to a markdown file and corrects a significant variable scoping issue in the analyze_field_utilization.sh script. The markdown changes improve rendering and readability. The fix in the shell script, changing from a pipe to process substitution for the while loop, correctly resolves the subshell scoping problem and is a great improvement. I've added a couple of suggestions for the shell script to further improve its robustness and maintainability by refactoring the JSON generation and making debug logging conditional. Overall, these are solid improvements.

Comment on lines +132 to +169
while IFS='|' read -r field_name field_mode field_type; do
# Simulate null percentage based on field patterns
# Real implementation would query actual data rows

log " Field: $table_name.$field_name, Mode: $field_mode, Type: $field_type"
null_pct=0

# Heuristic: Detect likely unused fields
if [[ "$field_name" =~ (legacy|old|deprecated|temp|unused|backup) ]]; then
log " Field: $table_name.$field_name, likely unused"
# Likely unused
null_pct=$((90 + RANDOM % 11)) # 90-100%
elif [[ "$field_mode" == "NULLABLE" ]] && [[ "$field_name" =~ (notes|comments|optional|metadata) ]]; then
log " Field Mode: $field_mode, likely low utilization"
# Likely low utilization
null_pct=$((60 + RANDOM % 30)) # 60-90%
elif [[ "$field_mode" == "REQUIRED" ]]; then
log " Field Mode: $field_mode, required field typically low null"
# Required fields typically low null
null_pct=$((0 + RANDOM % 20)) # 0-20%
else
log " Default: moderate utilization"
# Default: moderate utilization
null_pct=$((20 + RANDOM % 50)) # 20-70%
fi

# Categorize
log " Field: $table_name.$field_name, Estimated Null %: $null_pct"
if [ "$null_pct" -ge 90 ]; then
UNUSED_FIELDS+=("$table_name|$field_name|$null_pct")
log " Categorized as UNUSED ${#UNUSED_FIELDS[@]}"
elif [ "$null_pct" -ge 70 ]; then
LOW_UTIL_FIELDS+=("$table_name|$field_name|$null_pct")
log " Categorized as LOW UTIL ${#LOW_UTIL_FIELDS[@]}"
else
HIGH_UTIL_FIELDS+=("$table_name|$field_name|$null_pct")
log " Categorized as HIGH UTIL ${#HIGH_UTIL_FIELDS[@]}"
fi
done
done < <(jq -r '.schema[] | "\(.name)|\(.mode)|\(.type)"' "$file" 2>/dev/null)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The added logging is great for debugging. To make the script's output cleaner for regular use, consider making these detailed logs conditional. You could introduce a DEBUG environment variable or a command-line flag (e.g., -v or --verbose) to enable them. This would allow users to get detailed output only when they need to troubleshoot. For example, you could check for a variable at the top of your script and call log only if it's set.

Comment on lines 187 to 204
# Convert arrays to JSON
unused_json=$(printf '%s\n' "${UNUSED_FIELDS[@]}" | awk -F'|' '{print "{\"table\":\"" $1 "\",\"field\":\"" $2 "\",\"null_pct\":" $3 "}"}' | jq -s .)
low_util_json=$(printf '%s\n' "${LOW_UTIL_FIELDS[@]}" | awk -F'|' '{print "{\"table\":\"" $1 "\",\"field\":\"" $2 "\",\"null_pct\":" $3 "}"}' | jq -s .)
high_util_json=$(printf '%s\n' "${HIGH_UTIL_FIELDS[@]}" | awk -F'|' '{print "{\"table\":\"" $1 "\",\"field\":\"" $2 "\",\"null_pct\":" $3 "}"}' | jq -s .)

# Handle empty arrays
if [ ${#UNUSED_FIELDS[@]} -eq 0 ]; then
if [ ${#UNUSED_FIELDS[@]} -gt 0 ]; then
unused_json=$(printf '%s\n' "${UNUSED_FIELDS[@]}" | awk -F'|' '{print "{\"table\":\"" $1 "\",\"field\":\"" $2 "\",\"null_pct\":" $3 "}"}' | jq -s .)
else
unused_json="[]"
fi

if [ ${#LOW_UTIL_FIELDS[@]} -eq 0 ]; then
if [ ${#LOW_UTIL_FIELDS[@]} -gt 0 ]; then
low_util_json=$(printf '%s\n' "${LOW_UTIL_FIELDS[@]}" | awk -F'|' '{print "{\"table\":\"" $1 "\",\"field\":\"" $2 "\",\"null_pct\":" $3 "}"}' | jq -s .)
else
low_util_json="[]"
fi

if [ ${#HIGH_UTIL_FIELDS[@]} -eq 0 ]; then
if [ ${#HIGH_UTIL_FIELDS[@]} -gt 0 ]; then
high_util_json=$(printf '%s\n' "${HIGH_UTIL_FIELDS[@]}" | awk -F'|' '{print "{\"table\":\"" $1 "\",\"field\":\"" $2 "\",\"null_pct\":" $3 "}"}' | jq -s .)
else
high_util_json="[]"
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While checking for empty arrays before processing is more efficient, the JSON generation logic is repeated three times and uses awk to construct JSON strings. This can be fragile if table or field names contain special characters like quotes. A more robust and DRY (Don't Repeat Yourself) approach is to use a shell function that leverages jq for safe JSON creation. This also makes the code more readable and maintainable.

Suggested change
# Convert arrays to JSON
unused_json=$(printf '%s\n' "${UNUSED_FIELDS[@]}" | awk -F'|' '{print "{\"table\":\"" $1 "\",\"field\":\"" $2 "\",\"null_pct\":" $3 "}"}' | jq -s .)
low_util_json=$(printf '%s\n' "${LOW_UTIL_FIELDS[@]}" | awk -F'|' '{print "{\"table\":\"" $1 "\",\"field\":\"" $2 "\",\"null_pct\":" $3 "}"}' | jq -s .)
high_util_json=$(printf '%s\n' "${HIGH_UTIL_FIELDS[@]}" | awk -F'|' '{print "{\"table\":\"" $1 "\",\"field\":\"" $2 "\",\"null_pct\":" $3 "}"}' | jq -s .)
# Handle empty arrays
if [ ${#UNUSED_FIELDS[@]} -eq 0 ]; then
if [ ${#UNUSED_FIELDS[@]} -gt 0 ]; then
unused_json=$(printf '%s\n' "${UNUSED_FIELDS[@]}" | awk -F'|' '{print "{\"table\":\"" $1 "\",\"field\":\"" $2 "\",\"null_pct\":" $3 "}"}' | jq -s .)
else
unused_json="[]"
fi
if [ ${#LOW_UTIL_FIELDS[@]} -eq 0 ]; then
if [ ${#LOW_UTIL_FIELDS[@]} -gt 0 ]; then
low_util_json=$(printf '%s\n' "${LOW_UTIL_FIELDS[@]}" | awk -F'|' '{print "{\"table\":\"" $1 "\",\"field\":\"" $2 "\",\"null_pct\":" $3 "}"}' | jq -s .)
else
low_util_json="[]"
fi
if [ ${#HIGH_UTIL_FIELDS[@]} -eq 0 ]; then
if [ ${#HIGH_UTIL_FIELDS[@]} -gt 0 ]; then
high_util_json=$(printf '%s\n' "${HIGH_UTIL_FIELDS[@]}" | awk -F'|' '{print "{\"table\":\"" $1 "\",\"field\":\"" $2 "\",\"null_pct\":" $3 "}"}' | jq -s .)
else
high_util_json="[]"
fi
# A function to convert the internal array format to a JSON array.
# This is safer than using awk as it handles special characters in names.
array_to_json_array() {
if [ "$#" -eq 0 ]; then
echo "[]"
return
fi
printf '%s\n' "$@" | jq -R 'split("|") | {table: .[0], field: .[1], null_pct: (.[2] | tonumber)}' | jq -s .
}
# Convert arrays to JSON
unused_json=$(array_to_json_array "${UNUSED_FIELDS[@]}")
low_util_json=$(array_to_json_array "${LOW_UTIL_FIELDS[@]}")
high_util_json=$(array_to_json_array "${HIGH_UTIL_FIELDS[@]}")

@jeremylongshore jeremylongshore merged commit e78ce86 into jeremylongshore:main Jan 4, 2026
jeremylongshore pushed a commit that referenced this pull request Jan 4, 2026
Added claude-reflect to marketplace:
- Self-learning system that captures corrections during sessions
- Syncs learnings to CLAUDE.md automatically
- 3 commands, 2 hooks, 1 skill
- By @BayramAnnakov

Added to contributors list:
- @BayramAnnakov - claude-reflect plugin (#241)
- @jleonelion - Lab exercise fixes (#239)

Stats: 270 plugins (+1)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jeremylongshore
Copy link
Copy Markdown
Owner

🎉 Merged and credited, @jleonelion!

Your fixes are now live:

  • ✅ Markdown formatting fixed for proper copy-paste
  • ✅ Critical bash variable scoping bug fixed
  • ✅ Added to Contributors list in README

That bash subshell fix was a great catch - it's the kind of bug that's easy to miss but breaks everything. Thanks for making the Learning Lab better! 🔧

jeremylongshore pushed a commit that referenced this pull request Jan 4, 2026
## New
- claude-reflect plugin by @BayramAnnakov (#241)

## Fixed
- Schema validation error (#240) - strip zcf_metadata/external_sync
- Homepage Nixtla banner SVG rendering
- What's Live Now section layout
- claude-reflect skill 2025 schema compliance

## Contributors
- @BayramAnnakov - claude-reflect plugin
- @jleonelion - Lab exercise fixes (#239)
- @likeahoss - Reported #240

Stats: 270 plugins, 740 skills

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jleonelion
Copy link
Copy Markdown
Contributor Author

jleonelion commented Jan 5, 2026

🎉 Merged and credited, @jleonelion!

@jeremylongshore What you have going here is great work! I'm happy to contribute, even the little things, and look forward to seeing how this repo continues to improve.

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