GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(enterprise/coderd): extract AI model price body decoding and validation by SasSwart · Pull Request #30716 · coder/coder

Conversation

@SasSwart

@SasSwart SasSwart commented Oct 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Moves request body decoding and per-price validation out of the site-wide upsertAIModelPrices handler, so the organization price handler later in this stack can reuse them.

  • The handler still reads the body and writes the HTTP errors. writeAIModelPricesBodyReadError picks 413 or 400.
  • decodeAIModelPricesBody only decodes, and returns an error.
  • aiModelPriceKeys holds the JSON keys present in one price, so validation can tell an explicit null apart from a missing price.
  • validateAIModelPriceValues checks the four prices of one model price. It takes them as an aiModelTokenPrices struct, so callers set each price by name and cannot pass them in the wrong order.

No behavior change. The existing TestUpsertAIModelPrices, TestListAIModelPrices and TestValidateAIModelPrices cover the site-wide handler.

Used later: #30720 reuses the body read error, the price keys and the value validation for its single-price upsert.


This PR was generated by Coder Agents on behalf of @SasSwart.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@linear-code

linear-code Bot commented Oct 13, 2026

Copy link
Copy Markdown

AIGOV-612

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot assigned SasSwart Oct 13, 2026
This was referenced Oct 13, 2026
feat(coderd/database): add organization AI model config table #30717
Merged
feat(coderd): add queries for organization AI model prices #30718
Merged
feat(coderd): price token usage with organization prices #30719
Merged
feat: add organization AI model price API #30720
Closed
feat: add organization-scoped AI model prices #30690
Closed
@SasSwart
SasSwart added this pull request to stack #30737 October 14, 2026 06:51
@SasSwart
SasSwart force-pushed the sdlcgraph/aigov-612-1-price-validation branch from 40142e5 to 565c9b3 Compare October 14, 2026 12:42
SasSwart
SasSwart commented Oct 14, 2026
View reviewed changes

@SasSwart SasSwart left a comment

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Self review

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread enterprise/coderd/aimodelprices.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread enterprise/coderd/aimodelprices.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread enterprise/coderd/aimodelprices.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@SasSwart
SasSwart requested a review from ssncferreira October 14, 2026 15:47
@SasSwart
SasSwart marked this pull request as ready for review October 14, 2026 15:47
ssncferreira
ssncferreira approved these changes Oct 15, 2026
View reviewed changes

@ssncferreira ssncferreira left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread enterprise/coderd/aimodelprices.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

SasSwart added 3 commits October 19, 2026 10:56
@SasSwart
refactor(enterprise/coderd): extract AI model price body decoding and…
a4c8f59
… validation
@SasSwart
refactor(enterprise/coderd): keep HTTP handling out of AI model price…
8991978
… decoding

The handler reads the body and writes errors. decodeAIModelPricesBody only
decodes and returns an error. aiModelPriceKeys names the keys present in a
price, which tell an explicit null apart from a missing price.
@SasSwart
refactor(enterprise/coderd): pass AI model token prices as a struct
7542472
Group the four token prices passed to validateAIModelPriceValues into
aiModelTokenPrices, so callers set each price by name and cannot pass
them in the wrong order.
@SasSwart
SasSwart force-pushed the sdlcgraph/aigov-612-1-price-validation branch from f1faa97 to 7542472 Compare October 19, 2026 08:56
@SasSwart
SasSwart merged commit 41e5b2d into main Oct 19, 2026
29 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@SasSwart
SasSwart deleted the sdlcgraph/aigov-612-1-price-validation branch October 19, 2026 09:12
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@ssncferreira ssncferreira ssncferreira approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@SasSwart SasSwart

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@SasSwart @ssncferreira
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.