Skip to content

handle cost field#205

Merged
coryodaniel merged 4 commits intomainfrom
cost-nil-fix
Jan 28, 2026
Merged

handle cost field#205
coryodaniel merged 4 commits intomainfrom
cost-nil-fix

Conversation

@coryodaniel
Copy link
Member

@coryodaniel coryodaniel commented Jan 28, 2026

Summary

This PR updates the CLI to align with the new GraphQL cost API and surfaces the server version in mass version.

Changes

  • Cost schema alignment

    • Regenerated pkg/api/schema.graphql from the live API and updated zz_generated.go.
    • Updated Cost/Summary/CostSample handling so:
      • cost is now required on Environment, Project, and Package (matching Cost! in the schema).
      • CostSample.amount and currency are nullable and modeled as pointers in Go.
    • Adjusted Environment and Project structs to use value Cost (non-pointer), matching the now-required cost fields.
    • Updated tables and templates:
      • mass project list and mass environment list now read Cost.Monthly/Daily.Average.Amount directly, rendering empty cells when amount is null.
      • environment.get / project.get templates now print $<amount> when present and nothing when amount is null.
  • Runtime behavior

    • Verified against sandbox org: listing projects and environments continues to work with both populated and empty cost data.
    • Added tests in pkg/api/environment_test.go to cover the new Cost shape and pointer amount.
  • Version command

    • Extended mass version to:
      • Still print CLI version and git SHA.
      • Best-effort check for a newer CLI release and print the existing “newer version available” message.
      • Best-effort query the server and print the Mass server version when authentication succeeds.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the cost field handling across the codebase to support nullable amount and currency values. The changes address scenarios where cost data may not be available from the API.

Changes:

  • Updated GraphQL schema to make amount and currency fields nullable in CostSample type
  • Modified generated code to use pointer types (*float64) for nullable amount fields
  • Added display helper methods (DisplayAmount and DisplayAmountUSD) to handle null values gracefully
  • Updated templates and command handlers to check for nil costs and display "-" as fallback

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pkg/api/schema.graphql Made Cost fields (amount, currency) nullable and updated documentation
pkg/api/zz_generated.go Generated code changes to use pointer types for nullable amount fields
pkg/api/genqlient.graphql Added @genqlient(pointer: true) directives to amount fields in queries
pkg/api/cost.go Restructured Cost types, added Previous/Currency fields, and display helper methods
pkg/api/environment_test.go Updated test data to use pointer types for amount fields
cmd/project.go Added nil checks for Cost field before accessing display methods
cmd/environment.go Added nil checks for Cost field before accessing display methods
cmd/templates/project.get.md.tmpl Added conditional rendering for cost data with fallback for nil
cmd/templates/environment.get.md.tmpl Added conditional rendering for cost data with fallback for nil

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coryodaniel coryodaniel merged commit 52adf3d into main Jan 28, 2026
3 of 4 checks passed
@coryodaniel coryodaniel deleted the cost-nil-fix branch January 28, 2026 23:20
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