René's URL Explorer Experiment


Title: resource.update doesn't pass by_alias, mangling keyword-named fields · Issue #210 · crossplane/function-sdk-python · GitHub

Open Graph Title: resource.update doesn't pass by_alias, mangling keyword-named fields · Issue #210 · crossplane/function-sdk-python

X Title: resource.update doesn't pass by_alias, mangling keyword-named fields · Issue #210 · crossplane/function-sdk-python

Description: What happened? resource.update and resource.update_status serialize Pydantic models with model_dump(exclude_unset=True) (exclude_defaults=True before #208), neither of which passes by_alias=True. So a model field that carries a Pydantic ...

Open Graph Description: What happened? resource.update and resource.update_status serialize Pydantic models with model_dump(exclude_unset=True) (exclude_defaults=True before #208), neither of which passes by_alias=True. S...

X Description: What happened? resource.update and resource.update_status serialize Pydantic models with model_dump(exclude_unset=True) (exclude_defaults=True before #208), neither of which passes by_alias=True. S...

Opengraph URL: https://github.com/crossplane/function-sdk-python/issues/210

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"resource.update doesn't pass by_alias, mangling keyword-named fields","articleBody":"### What happened?\n\n`resource.update` and `resource.update_status` serialize Pydantic models with `model_dump(exclude_unset=True)` (`exclude_defaults=True` before #208), neither of which passes `by_alias=True`. So a model field that carries a Pydantic alias is serialized under its **Python attribute name** rather than its alias, and the alias is the resource's real wire/JSON name.\n\nThis bites fields whose KRM name is a Python keyword. `datamodel-code-generator` (which `crossplane xpkg generate` / the CLI uses to generate models) can't name a field `bool`, `int`, `from`, `continue`, or `schema`, so it emits a `bool_` attribute aliased to `bool`, `int_` aliased to `int`, and so on. When a function composes a resource that sets such a field, `resource.update` writes the Python name into the desired resource:\n\n```python\ndata = source.model_dump(exclude_unset=True, warnings=False)\n# -\u003e {\"bool_\": True}, but the resource's field is \"bool\"\n```\n\nThe composed resource then carries `bool_: true` instead of `bool: true`, which doesn't match the resource's schema. The API server rejects it (or silently drops the unknown field), and the field the function set never takes effect.\n\nThis surfaced with Kubernetes Dynamic Resource Allocation, whose device attribute value is a one-of over `string`, `version`, `bool`, and `int`. `bool` and `int` generate aliased fields, so any function composing a DRA `ResourceClaim` / device attribute through a generated model hits this.\n\n### How can we reproduce it?\n\nGenerate a model for a CRD with a field named `bool` (or `int`/`from`/`continue`/`schema`), then compose it:\n\n```python\n# Generated model: bool_ aliased to \"bool\".\nattrs = Attributes(**{\"bool\": True})\n\nattrs.model_dump(exclude_unset=True)\n# {'bool_': True}   \u003c- wrong key in the composed resource\n\nattrs.model_dump(exclude_unset=True, by_alias=True)\n# {'bool': True}    \u003c- correct wire name\n```\n\n`resource.update` uses the first form, so the desired resource ends up with `bool_`.\n\n### How could the SDK help solve it?\n\nPass `by_alias=True` alongside `exclude_unset=True` in both `resource.update` and `resource.update_status`.\n\nIt's a safe, general fix. `datamodel-code-generator` only aliases fields whose names collide with Python keywords; every ordinary field — including camelCase ones like `clusterName` — is generated with the wire name as the attribute name and no alias, so `by_alias=True` is a no-op for them and corrects only the keyword cases. It's also orthogonal to the `exclude_unset` change in #208: one decides which fields are emitted, the other how they're named.\n\n### What environment did it happen in?\n\n- crossplane/function-sdk-python: `main` (and the `exclude_unset` branch from #208)\n- Models generated by `datamodel-code-generator` via the Crossplane CLI, which emits keyword-collision field aliases (see crossplane/cli#63, crossplane/cli#64)\n","author":{"url":"https://github.com/negz","@type":"Person","name":"negz"},"datePublished":"2026-06-08T20:09:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/210/function-sdk-python/issues/210"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:888ea569-92f3-ff34-7a56-4d2da10ead21
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA174:359CE8:128AC2:19470A:6A5FB859
html-safe-noncea680bfe729db780836d16752bbbe610322874c9f81981bc0f30a070098f51948
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTc0OjM1OUNFODoxMjhBQzI6MTk0NzBBOjZBNUZCODU5IiwidmlzaXRvcl9pZCI6IjkwMzg0OTI2MzMwNTc0NDE4ODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac225d28222e362d218ca2d72282c48fa1efdbbc556ebbbd36d83dd497e090af14
hovercard-subject-tagissue:4616261865
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/crossplane/function-sdk-python/210/issue_layout
twitter:imagehttps://opengraph.githubassets.com/ea7dd8d33cc9c13e1e1f2f98e7db26f58d25da4042964d2fe2dd87c9dcccb776/crossplane/function-sdk-python/issues/210
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ea7dd8d33cc9c13e1e1f2f98e7db26f58d25da4042964d2fe2dd87c9dcccb776/crossplane/function-sdk-python/issues/210
og:image:altWhat happened? resource.update and resource.update_status serialize Pydantic models with model_dump(exclude_unset=True) (exclude_defaults=True before #208), neither of which passes by_alias=True. S...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamenegz
hostnamegithub.com
expected-hostnamegithub.com
Nonee0cfc367faf9c4c774d2a903897aa214c786247c4f45ffcee48cda2b819fb0c8
turbo-cache-controlno-preview
go-importgithub.com/crossplane/function-sdk-python git https://github.com/crossplane/function-sdk-python.git
octolytics-dimension-user_id45158470
octolytics-dimension-user_logincrossplane
octolytics-dimension-repository_id721365259
octolytics-dimension-repository_nwocrossplane/function-sdk-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id721365259
octolytics-dimension-repository_network_root_nwocrossplane/function-sdk-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release94569c859bc88d6bf7de7e0ce3f2a11cd529a131
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/crossplane/function-sdk-python/issues/210#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcrossplane%2Ffunction-sdk-python%2Fissues%2F210
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcrossplane%2Ffunction-sdk-python%2Fissues%2F210
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=crossplane%2Ffunction-sdk-python
Reloadhttps://github.com/crossplane/function-sdk-python/issues/210
Reloadhttps://github.com/crossplane/function-sdk-python/issues/210
Reloadhttps://github.com/crossplane/function-sdk-python/issues/210
Please reload this pagehttps://github.com/crossplane/function-sdk-python/issues/210
crossplane https://github.com/crossplane
function-sdk-pythonhttps://github.com/crossplane/function-sdk-python
Notifications https://github.com/login?return_to=%2Fcrossplane%2Ffunction-sdk-python
Fork 14 https://github.com/login?return_to=%2Fcrossplane%2Ffunction-sdk-python
Star 13 https://github.com/login?return_to=%2Fcrossplane%2Ffunction-sdk-python
Code https://github.com/crossplane/function-sdk-python
Issues 6 https://github.com/crossplane/function-sdk-python/issues
Pull requests 1 https://github.com/crossplane/function-sdk-python/pulls
Actions https://github.com/crossplane/function-sdk-python/actions
Projects https://github.com/crossplane/function-sdk-python/projects
Security and quality 0 https://github.com/crossplane/function-sdk-python/security
Insights https://github.com/crossplane/function-sdk-python/pulse
Code https://github.com/crossplane/function-sdk-python
Issues https://github.com/crossplane/function-sdk-python/issues
Pull requests https://github.com/crossplane/function-sdk-python/pulls
Actions https://github.com/crossplane/function-sdk-python/actions
Projects https://github.com/crossplane/function-sdk-python/projects
Security and quality https://github.com/crossplane/function-sdk-python/security
Insights https://github.com/crossplane/function-sdk-python/pulse
#208https://github.com/crossplane/function-sdk-python/pull/208
resource.update doesn't pass by_alias, mangling keyword-named fieldshttps://github.com/crossplane/function-sdk-python/issues/210#top
#208https://github.com/crossplane/function-sdk-python/pull/208
https://github.com/negz
https://github.com/negz
negzhttps://github.com/negz
on Jun 8, 2026https://github.com/crossplane/function-sdk-python/issues/210#issue-4616261865
#208https://github.com/crossplane/function-sdk-python/pull/208
#208https://github.com/crossplane/function-sdk-python/pull/208
Serialize models with exclude_unset, not exclude_defaults #208https://github.com/crossplane/function-sdk-python/pull/208
crossplane project build generates broken Python schemas for OpenAPI fields named int/bool cli#63https://github.com/crossplane/cli/issues/63
Fix Python schema generation for fields named int or bool cli#64https://github.com/crossplane/cli/pull/64
negzhttps://github.com/negz
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.