API version updates
The runbook for updating the SDK when SAS ships a new version of a Visual Investigator service API. Follow it top to bottom; every step tells you what "good" looks like and what to do when it isn't.
How the pipeline works (30 seconds)
SAS's published OpenAPI specs are the source of truth. The repository does not
ship them: tools/generate_sdk/_specs.py pins each one by its developer.sas.com
URL and SHA-256 (the lock), and python -m tools.generate_sdk --fetch
downloads them into openapi_definitions/. Generation refuses any file whose
bytes differ from the lock. python -m tools.generate_sdk normalizes each spec, runs the pinned
openapi-python-client generator, applies a registry of documented
post-generation patches, and syncs the result into src/sasvi/_generated/ and
src/sasvi/api/. Regeneration is deterministic; CI byte-compares the committed
output via --check.
Module-by-module detail: tools/generate_sdk/README.md in the repository.
1. Get the specs
The pinned specs
Every contributor who regenerates or runs the generator tests needs these. No SAS account is needed.
.venv/bin/python -m tools.generate_sdk --fetch
The command downloads each spec, hashes it, and writes it to
openapi_definitions/ only when the hash matches the lock. tools.verify runs this step first, so the gate
fetches the files on its own. To see the lock and the state of your local
files:
.venv/bin/python -m tools.generate_sdk --list-specs
Without the files, the tests that read them skip with the fetch command in the skip reason. A local file that differs from the lock fails those tests, and generation refuses to start. Delete the file and fetch again.
Set SASVI_OPENAPI_DIR to keep the files somewhere other than
openapi_definitions/.
When the download is blocked
If a proxy blocks --fetch, download each file in a browser:
-
Open the service's page on developer.sas.com. The page is
https://developer.sas.com/rest-apis/<slug>, where<slug>is the part of the lock URL after/api/apis/(for examplesvi-datahub-v10). -
In SAS Viya Version, pick a release that ends in the major version the lock names (
v10for Data Hub). The list shows every Viya release next to the API major it ships.
-
Click Download. For a given major, the button always serves the same file the lock URL does.

-
Save the file in
openapi_definitions/under the name in the lock'sFilecolumn (svi-datahub-v10-openapi.yml), then run--list-specs. Every row should readok.
A new or changed spec
SAS updates each major's file in place, and sometimes ships a new major. In both
cases --fetch fails. It keeps the download under build/spec_refresh/ and
prints the new SHA-256. For a new major, download the new file the same way
(the lock URL with the new major, for example svi-datahub-v11) into
build/spec_refresh/.
Never hand-edit a spec file. Every fix belongs in the normalization or patch layer, where it is documented and survives the next refresh.
2. Diff it against the pinned spec
.venv/bin/python -m tools.spec_diff \
openapi_definitions/svi-datahub-v10-openapi.yml \
build/spec_refresh/svi-datahub-v10-openapi.yml
The report groups: operations added/removed/changed (parameters, request content types, response codes), raw methods renamed, tag changes, schemas added/removed, enum value changes, and newly required fields. It always exits 0. Pay special attention to:
- Renamed raw methods. A line such as
! RENAMED client.api.datahub.get_things -> list_thingsmeans the spec changed anoperationId, and the raw method name comes from that id. The report runs the generator's own id normalization, so the names are the ones a caller types. This is a breaking change for anyone on the raw layer: grep the handwritten code for the old name and give the rename aChanged (breaking).changelog entry with a**Migration:**line. A tag change only moves the generated module (moves api/things/ -> api/stuff/) and leavesclient.api.<svc>.<method>alone, unless the operation has no usable id, in which case the id is built from the tag and the report shows the rename too. - Removed operations and schemas. Handwritten code may depend on them. The raw facades carry the generated operations' own types and mypy analyses the generated package, so a removed schema, a renamed parameter or a changed parameter type fails the gate after regeneration instead of surfacing on the wire.
- Newly required parameters and fields. These break callers at runtime, not at generation time.
- Enum value changes. Check whether a patch in the registry
(
python -m tools.generate_sdk --list-patches) was adding the value manually and can now be deleted.
3. Update the service registry
In tools/generate_sdk/_specs.py, update the service's SERVICE_SPECS
entry: sha256, and for a new major also source, url and spec_version.
Update the same row in openapi_definitions/SOURCES.md;
tests/test_manifest.py fails while the two disagree. Then move the new file
from build/spec_refresh/ into openapi_definitions/, delete the old one, and
check with --list-specs.
4. Regenerate
.venv/bin/python -m tools.generate_sdk --service datahub
Read the output: each service prints which patches were applied
(datahub: applied 6 patches (P-01, P-02, ...)) and the run finishes by
rewriting the spec-version manifest. Then review the diff of
src/sasvi/_generated/<service>/ like any code change. Operation renames, removed
models, and typing changes show up here first.
5. Patch failures
A patch failure looks like this and is expected during version bumps. It means the generated code no longer looks like what the patch was written against:
PatchError: Patch P-04 (datahub) failed: target file models/data_field_data_type.py does not exist in the generated output.
Why this patch exists: platform uses enum value USER_GROUP that the spec omits.
Upstream: Data Hub spec defect; delete once upstream adds the value.
...
Triage decision tree:
- Did the new spec fix the underlying defect? (Check the spec_diff
output and the patch's reason.) → Delete the patch's entry from
REGISTRYintools/generate_sdk/_patches.py. This is the happy path, because patches are supposed to die this way. The failure that says so outright isthe patch changed nothing: patches always run over freshly generated code, so a patch with nothing left to change means the fix is already there. - Did the target file move or get renamed? (Schema renames change model
filenames.) → Update the patch's
targetsand anyrelative_pathin itsapplypartial. - Did the generated layout drift but the defect remains? → Adapt the
patch function, and extend the corresponding test in
tests/test_generation.pyso the new layout is pinned.
P-46 is the one patch that rewrites every operation, so it fails first when
the generator changes its _build_response or error-branch layout. Its failure
names the file and, for an unknown model in a 4xx/5xx branch, the model. Adding
a new error model to a service means adding it to _ERROR_MODEL_NAMES in
tools/generate_sdk/_patches.py: the patch refuses to guess, because an
unrecognised error body escaping as a plain exception is the failure this patch exists to stop.
P-47 runs last and rewrites every enum file and most models, so that a value
the spec does not know no longer fails the whole response. Every
check_* returns an unlisted value unchanged and logs it once at WARNING
through <service>/_tolerant.py. A typed optional key that arrives as null
reads as absent, and a required list that arrives as null reads as empty. A
required scalar or nested model that is missing still raises, and the error
names the model path and the key. P-47 fails in three ways:
Unexpected enum check layoutnames an enum file whosecheck_*no longer ends in theraise TypeError(...)the patch replaces. Adapt_ENUM_CHECK_PATTERN. Do not skip the file: onecheck_*left raising brings the whole-response failure back for that enum.below the floorsmeans the tree yielded fewer rewrite sites than_TOLERANCE_FLOORSexpects for the service, so thefrom_dictlayout has changed. Fix the pop patterns first, then lower a floor only if the spec really shrank. A new service needs its own row.Unexpected MalformedResponse layoutmeansP-46changed its helper text. The two patches share that text, so change them together.
The SAS Logon tree records the model path of a parse failure but not the
reason, because the exception text can quote a token out of the body. Keep
saslogon in _REASON_REDACTED_SERVICES.
When a tenant logs Response carries <Enum> value '<x>' that the API spec does not list, nothing is broken. File the value in Upstream-Spec-Issues.md, which sits
next to this page in the repository's website/docs/Contributing/ directory but is not
published on this site. Add an add_enum_value patch
(like P-04) only when handwritten code branches on the value or every healthy
tenant emits it, so that the WARNING keeps meaning "this tenant is ahead of the
spec".
After any registry change, re-run the regeneration and check
tests/test_patch_registry.py still passes. It validates registry consistency
against the committed generated tree.
6. Handwritten-layer follow-ups
Regeneration can require follow-up changes in handwritten code when operations are renamed/removed or semantics change. Work through, in order:
src/sasvi/api. Regenerated automatically, but review the diff. Two operations that would claim the same facade method name now fail generation rather than one silently overwriting the other; resolve it in the spec normalizer, or add the name toALLOWED_OPERATION_NAME_COLLISIONSwith the reason (seetools/generate_sdk/_facade.py).src/sasvi/_client.py,src/sasvi/_runtime.py. Client wiring.- Feature modules.
src/sasvi/documents,alerts,search,workflows,reference_lists,entities,insights. README.md,website/docs/,examples/. User-facing guidance.
mypy plus the offline suite catch renamed/removed symbols. What they cannot
catch: runtime shape changes (a field the server stops sending arrives as
Unset, and a new enum value arrives as a string outside the Literal),
newly required request fields, and status-code changes. Run the live
suite against a tenant on the new cadence when possible
(python -m tools.live_run --smoke).
7. Verify and ship
.venv/bin/python -m tools.verify # includes the --check drift gate
.venv/bin/sasvi doctor # spec-manifest row shows the new versions
Then update the compatibility matrix in
website/docs/concepts/compatibility-and-viya-cadence.md following the rules in the
Maintenance guide,
and add a CHANGELOG entry when the regeneration changed public behavior.
Note: the spec-version manifest also embeds the generator version, so bumping
the openapi-python-client pin requires a full regeneration commit. That is
intentional, because a generator upgrade can change every generated file.
Adding a new service
Steps 1 to 7 assume the service is already registered. A brand-new spec needs wiring in more places, several of them hand-maintained lists that nothing fails on if you forget them:
-
Find the spec's download URL on developer.sas.com (step 1) and add a row to the table in
openapi_definitions/SOURCES.md. -
tools/generate_sdk/_specs.py: add aSERVICE_SPECSentry (key, source,package_dir,default_path,spec_title,spec_version,url,sha256) and aFACADE_CLASS_NAMESentry. Without the facade name, nosrc/sasvi/api/<service>.pyis generated. -
python -m tools.generate_sdk --service <service>. Check the output for internal operations you expected to keep (x-sas-internal: trueones are dropped) and for duplicate branches or missing imports. -
Runtime wiring:
src/sasvi/_client.py: facade import,SERVICE_DEFINITIONS,RAW_API_CLASSES, and theAPINamespace(...)constructionsrc/sasvi/api/_namespace.py: a field onAPINamespacesrc/sasvi/api/__init__.py: import and__all__src/sasvi/types/<service>.py: thefrom .._generated.<service>.types import *shim, plus the_forward(...)line when the service's models should be public (copysrc/sasvi/types/alerts.py), listed in thesasvi.typesdocstring
Preview mode stubs every
APINamespacefield automatically, andtests/test_preview_runtime.pyfails if a registered service is missing from the namespace. -
Tests: the
isinstancenamespace check intests/test_runtime.py, the shim import intests/test_module_shims.py, and service-specific assertions intests/test_generation.py.tests/test_manifest.pypasses once the regenerated_generated/_manifest.pyis committed. -
Docs that list services by hand:
README.md,website/docs/Contributing/Architecture.md,website/docs/Guides/SVIClient-and-API-Layers.md,website/docs/concepts/client-model.md,website/docs/api/index.md,website/docs/concepts/compatibility-and-viya-cadence.md, and the server-path list inUpstream-Spec-Issues.md(in the repository, next to this page; not published).
Monthly cadence refreshes with no changes
Whether a cadence needs regeneration is decided by the spec bytes, not by the
tools.spec_diff report. Download every spec again and compare it with the
lock:
.venv/bin/python -m tools.generate_sdk --fetch --force
When every spec matches, the committed clients were generated from the published files and no regeneration is needed: append the cadence to the existing compatibility-matrix row as described in the Maintenance guide.
When any spec differs, --fetch says which, and keeps the new file under
build/spec_refresh/. Work through steps 2 to 7, then regenerate and commit
the result, whatever
tools.spec_diff reports. The diff report is a reading aid for the review; it
classifies operations, parameters, media types, enums and required fields, and
lists everything else under Schemas with other changes and per-operation
schema: lines, but a changed spec with a quiet report is still a changed spec.
python -m tools.generate_sdk --check is the gate: it regenerates from the
pinned spec files and fails when the committed clients or the manifest
digests differ from that output.