Skip to content

Commit

Permalink
fix(python): the python generator no longer fails hard if there is no…
Browse files Browse the repository at this point in the history
… API ID on the IR (#4743)
  • Loading branch information
armandobelardo committed Sep 26, 2024
1 parent 2c5bf84 commit 08b669c
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/write-changelogs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ on:
jobs:
write-changelogs:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -55,3 +54,4 @@ jobs:
with:
commit_message: "chore: update changelog"
add_options: "-A ./fern/pages/changelogs"
token: ${{ secrets.FERN_GITHUB_PAT }}
2 changes: 1 addition & 1 deletion fern/pages/changelogs/cli/2024-09-25.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.43.1
**`(feat):`** The CLI now supports running OpenAPI generator 0.1.0 with IR version 53.
**`(feat):`** The CLI now supports running OpenAPI generator 0.1.0 with IR version 53.


1 change: 1 addition & 0 deletions fern/pages/changelogs/cli/2024-09-26.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## 0.43.2

**`(fix):`** The CLI now prints which API cannot be registered if `fern generate --docs` fails.


10 changes: 9 additions & 1 deletion generators/python/sdk/versions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# For unreleased changes, use unreleased.yml
# For unreleased changes, use unreleased.yml
- version: 4.2.7-rc3
irVersion: 53
changelogEntry:
- type: fix
summary: |
Now, when sending Snippet Templates back to Fern, the generator will not try to coerce a potentially missing ID into the `api_definition_id` field.
This, had been a cause of the error log `Failed to upload snippet templates to FDR, this is ok: one of the hex, bytes, bytes_le, fields, or int arguments must be given`.
- version: 4.2.7-rc2
irVersion: 53
changelogEntry:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,24 @@ def _maybe_write_snippet_templates(
if fdr_client is not None:
# API Definition ID doesn't matter right now
try:
api_definition_id = uuid4()
if ir.fdr_api_definition_id is not None:
try:
api_definition_id = uuid.UUID(ir.fdr_api_definition_id)
except Exception as e:
generator_exec_wrapper.send_update(
GeneratorUpdate.factory.log(
LogUpdate(
level=LogLevel.DEBUG,
message=f"Failed to convert FDR API Definition ID to UUID: {str(e)}, generating a new one.",
)
)
)

fdr_client.templates.register_batch(
org_id=org_id,
api_id=api_name,
api_definition_id=uuid.UUID(ir.fdr_api_definition_id) or uuid4(),
api_definition_id=api_definition_id,
snippets=snippets,
)
generator_exec_wrapper.send_update(
Expand Down
12 changes: 10 additions & 2 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
- changelogEntry:
- summary: |
The CLI now prints which API cannot be registered if `fern generate --docs` fails.
The CLI now passes in the API definition ID once again, this is necessary so that generated snippet templates
may reference schemas within the API. This was a regression that was recently introduced.
type: chore
irVersion: 53
version: 0.43.3

- changelogEntry:
- summary: |
The CLI now prints which API cannot be registered if `fern generate --docs` fails.
type: fix
irVersion: 53
version: 0.43.2

- changelogEntry:
- summary: |
The CLI now supports running OpenAPI generator 0.1.0 with IR version 53.
The CLI now supports running OpenAPI generator 0.1.0 with IR version 53.
type: feat
irVersion: 53
version: 0.43.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export async function runRemoteGenerationForGenerator({
version,
intermediateRepresentation: {
...ir,
fdrApiDefinitionId,
publishConfig: getPublishConfig({ generatorInvocation: generatorInvocationWithEnvVarSubstitutions })
},
shouldLogS3Url,
Expand Down

0 comments on commit 08b669c

Please sign in to comment.