Skip to content

Conversation

@begna112
Copy link

Summary

  • Bug fixes: Mutable default arguments, timezone display, raw mode returns, safe dict access, retry logic for 429/502/503/504, timeout handling, subprocess shell injection prevention, and more
  • Help text improvements: Clearer descriptions, consistent formatting, and better argument documentation across all CLI commands
  • Test infrastructure: 547 tests covering regression, smoke, and unit tests with CI pipeline (lint, test matrix across 3 OS x 5 Python versions, standalone smoke tests)
  • Build configuration: pyproject.toml with dev dependencies, Ruff linting, coverage reporting

Changes

vast.py

  • Fixed mutable default json={} arguments in http_put, http_post, http_del
  • Fixed timezone display (UTC timestamps were showing local time labeled as "UTC")
  • Fixed 31+ functions returning Response objects instead of parsed JSON in raw mode
  • Fixed query parser field alias bug where v referenced already-popped dict key
  • Fixed show__instances() loop not storing modified rows back to list
  • Fixed show__machine() to handle single dict response (not just list)
  • Fixed hardcoded if True: in search__benchmarks, search__invoices, search__templates
  • Added retry logic for 429, 502, 503, 504 status codes and connection errors
  • Added configurable timeouts (30s default, 120s for file ops)
  • Added DRY helpers: api_call(), output_result(), error_output(), require_id()
  • Removed shell=True from SSH/SCP subprocess calls (security)
  • Replaced bare except: clauses with specific exception types
  • Replaced deprecated utcfromtimestamp() with fromtimestamp(ts, tz=timezone.utc)

Tests (new)

  • 23 regression tests covering each bug fix
  • Smoke tests for CLI commands and standalone mode
  • Unit tests for HTTP helpers, query parser, and timezone handling

CI (new)

  • .github/workflows/ci.yml: Ruff lint, pytest across ubuntu/macos/windows x Python 3.9-3.13, standalone smoke tests
  • pyproject.toml: Build config, dev dependencies, coverage thresholds

Test plan

  • python vast.py --help works
  • python vast.py search offers --help shows improved help text
  • pytest tests/ passes (all 547 tests)
  • ruff check vast.py passes
  • CI pipeline passes on all matrix combinations

Bug fixes:
- Fix mutable default arguments in http_put/post/del
- Add missing exception handling in http_request
- Fix timezone handling with UTC-aware timestamps
- Fix show_instances row rebinding bug
- Fix show_machine dict response handling
- Fix parse_query field alias data loss
- Remove hardcoded if True anti-patterns
- Fix raw mode to return parsed JSON consistently
- Fix namespace attribute typo
- Replace bare except clauses with specific exceptions
- Remove shell=True from subprocess calls
- Fix self-test instance creation type handling and error messages

Infrastructure improvements:
- Add request timeout support with configurable defaults
- Expand retry logic to cover 502/503/504 and connection errors
- Add JSONDecodeError protection to high-risk .json() sites
- Consolidate direct requests calls through http_* helpers
- Add structured JSON error output for --raw mode
- Add raw mode return handling to all command functions
- Remove unreachable code after raise_for_status()
- Add api_call/output_result/error_output DRY helpers
- Add 2FA session expiry handling with automatic key fallback
- Filter sensitive fields from show endpoints output

CLI improvements:
- Improve help text and descriptions for 130+ commands
- Add named flags for transfer credit (--sender, --recipient)
- Fix argument mismatches in usage strings
- Standardize show maints to use --ids instead of -ids
- Remove Python 2 compatibility code

Test infrastructure:
- Add pytest with regression, smoke, and unit test suites
- Add CI workflow with lint, test, and smoke-test jobs
- Add ruff configuration for code quality
- Add dev dependencies to pyproject.toml
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.

1 participant