fix: recover from upstream parser panic to keep LS alive - #140
Conversation
Wraps config.ParseConfigString and config.ReadStackConfigString in recover() shims so an unresolvable remote_state block (read_terragrunt_config inside a try) no longer crashes the language server. Includes a regression test based on the reproducer. Fixes gruntwork-io#134 Signed-off-by: SAY-5 <say.apm35@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR adds panic recovery handlers to two parsing functions. When Terragrunt's parser panics on malformed configurations, the new wrappers catch those panics, convert them to errors (with filename and stack trace), and return ChangesPanic-Safe Parser Wrappers
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #134.
When opening a
root.hclwhoseremote_stateblock depends on values produced byread_terragrunt_config/find_in_parent_foldersthat cannot be resolved during LS parsing, the upstream Terragrunt parser passes a nil*remotestate.Configtoremotestate.New, which dereferencesconfig.BackendNameand panics. Because the parser runs in-process, the LS crashes for every open editor window.This change wraps
config.ParseConfigStringandconfig.ReadStackConfigStringinrecover()shims at the LS boundary so a panic becomes a logged error and a nil config, matching the parser's existing error path. A regression test based on the reporter's reproducer is included.Summary by CodeRabbit
Bug Fixes
Tests