fix: handle empty description in class generator#2677
Conversation
When API schema has description: "" (empty string), dict.get() returns the empty string instead of falling back to MISSING_DESCRIPTION_STR, causing empty class docstrings. Use 'or' instead of get() default to handle both missing and empty/falsy description values.
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe explain_parser description retrieval now applies a fallback default description when the description is missing or evaluates as falsy (e.g., empty string), instead of only when the key is absent from the schema. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
|
/verified |
|
/lgtm |
Problem
When the OpenAPI schema has an empty
descriptionfield (e.g.,LlamaStackDistribution), runningclass-generator --kind <Kind> --overwriteproduces an empty class docstring (""" """), replacing any previously correct fallback text.The root cause:
dict.get("description", MISSING_DESCRIPTION_STR)returns""(empty string) when the key exists but is empty, instead of falling back to the default.Fix
Changed
_kind_schema.get("description", MISSING_DESCRIPTION_STR)to_kind_schema.get("description") or MISSING_DESCRIPTION_STRinexplain_parser.py.Using
orensures both missing keys and empty/falsy values fall back to"No field description from API".Reproduction
Summary by CodeRabbit