René's URL Explorer Experiment


Title: Serialize models with exclude_unset, not exclude_defaults by negz · Pull Request #208 · crossplane/function-sdk-python · GitHub

Open Graph Title: Serialize models with exclude_unset, not exclude_defaults by negz · Pull Request #208 · crossplane/function-sdk-python

X Title: Serialize models with exclude_unset, not exclude_defaults by negz · Pull Request #208 · crossplane/function-sdk-python

Description: Fixes #207 Fixes #210 resource.update and resource.update_status serialized Pydantic models with model_dump(exclude_defaults=True). This PR makes two related corrections to how those functions serialize models. exclude_defaults → exclude_unset exclude_defaults asks "is this field different from its default?". The correct question for server-side apply is "did the caller set this field?", which exclude_unset answers. exclude_defaults also regressed with newer datamodel-code-generator, which emits object defaults as a raw dict with validate_default=True; the validated instance doesn't compare equal to the declared dict default, so unset fields like spec.providerConfigRef leaked into every composed resource. exclude_unset is immune to how a default is represented (see crossplane/cli#64 (comment)) — a field the caller didn't touch is absent from model_fields_set. Add by_alias=True Neither serialization passed by_alias=True, so a field carrying a Pydantic alias was emitted under its Python attribute name rather than its alias — the resource's real wire name. datamodel-code-generator can't name a field bool, int, from, continue, or schema, so it emits a bool_ attribute aliased to bool, and so on. A function composing such a field wrote bool_: true instead of bool: true, which doesn't match the resource's schema, so the API server rejects it or silently drops it. This surfaced with Kubernetes Dynamic Resource Allocation, whose device attribute value is a one-of over string, version, bool, and int. Passing by_alias=True is a no-op for ordinary fields and corrects only the keyword-collision cases. It's also symmetric with how pydantic deserializes these models: by default an aliased field is populated only by its alias, so reads and writes now both speak wire names. It's orthogonal to the exclude_unset change: one decides which fields are emitted, the other how they're named. I have: Read and followed Crossplane's contribution process. Added or updated unit tests for my change.

Open Graph Description: Fixes #207 Fixes #210 resource.update and resource.update_status serialized Pydantic models with model_dump(exclude_defaults=True). This PR makes two related corrections to how those functions seri...

X Description: Fixes #207 Fixes #210 resource.update and resource.update_status serialized Pydantic models with model_dump(exclude_defaults=True). This PR makes two related corrections to how those functions seri...

Opengraph URL: https://github.com/crossplane/function-sdk-python/pull/208

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:a7674d9f-d6fa-1260-784d-6eee940c0db6
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idACE6:3E74E8:16106D1:1EA088E:6A61C17D
html-safe-nonced145e06d72036c1726f57abd062a4ec7e05b745f8f078424da851f00beb1fb61
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQ0U2OjNFNzRFODoxNjEwNkQxOjFFQTA4OEU6NkE2MUMxN0QiLCJ2aXNpdG9yX2lkIjoiNjc4MTIwMDY3NzE4NzIwNzU0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacb56ea1616616e571e38bae20f7e496d6b5dfe4039f4a98839ce1063ade796928
hovercard-subject-tagpull_request:3799550577
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/crossplane/function-sdk-python/pull/208/files
twitter:imagehttps://avatars.githubusercontent.com/u/1049349?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1049349?s=400&v=4
og:image:altFixes #207 Fixes #210 resource.update and resource.update_status serialized Pydantic models with model_dump(exclude_defaults=True). This PR makes two related corrections to how those functions seri...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None6f4633bcf01c1ad14b73fd07dd39ac31d61f3d3c2578ee08ec1792b7b351eeb9
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseac296ae7f21856f1f92adbad22f870b6fbb4b907
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/crossplane/function-sdk-python/pull/208/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcrossplane%2Ffunction-sdk-python%2Fpull%2F208%2Ffiles
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%2Fpull%2F208%2Ffiles
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%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=crossplane%2Ffunction-sdk-python
Reloadhttps://github.com/crossplane/function-sdk-python/pull/208/files
Reloadhttps://github.com/crossplane/function-sdk-python/pull/208/files
Reloadhttps://github.com/crossplane/function-sdk-python/pull/208/files
Please reload this pagehttps://github.com/crossplane/function-sdk-python/pull/208/files
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
Sign up for GitHub https://github.com/signup?return_to=%2Fcrossplane%2Ffunction-sdk-python%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fcrossplane%2Ffunction-sdk-python%2Fissues%2Fnew%2Fchoose
negzhttps://github.com/negz
crossplane:mainhttps://github.com/crossplane/function-sdk-python/tree/main
negz:best-left-unsethttps://github.com/negz/function-sdk-python/tree/best-left-unset
Conversation 2 https://github.com/crossplane/function-sdk-python/pull/208
Commits 2 https://github.com/crossplane/function-sdk-python/pull/208/commits
Checks 6 https://github.com/crossplane/function-sdk-python/pull/208/checks
Files changed https://github.com/crossplane/function-sdk-python/pull/208/files
Please reload this pagehttps://github.com/crossplane/function-sdk-python/pull/208/files
Serialize models with exclude_unset, not exclude_defaults https://github.com/crossplane/function-sdk-python/pull/208/files#top
Show all changes 2 commits https://github.com/crossplane/function-sdk-python/pull/208/files
572ae75 Serialize models with exclude_unset, not exclude_defaults negz Jun 4, 2026 https://github.com/crossplane/function-sdk-python/pull/208/commits/572ae7589a04cf10b94e43176138aaa9eb042d1b
d18cbbb Pass by_alias when serializing models in update and update_status negz Jun 8, 2026 https://github.com/crossplane/function-sdk-python/pull/208/commits/d18cbbb481bb9859b2f58625050d6482201cc021
Clear filters https://github.com/crossplane/function-sdk-python/pull/208/files
Please reload this pagehttps://github.com/crossplane/function-sdk-python/pull/208/files
Please reload this pagehttps://github.com/crossplane/function-sdk-python/pull/208/files
resource.py https://github.com/crossplane/function-sdk-python/pull/208/files#diff-05f183177eba52e1720d1fb16381620d80c3a5f071a87aa09b57177df0f33934
test_resource.py https://github.com/crossplane/function-sdk-python/pull/208/files#diff-cbf27c7a6a4139890bca166895b931c6ad62cff4f4c3bb341cc5eac6757a74b6
__init__.py https://github.com/crossplane/function-sdk-python/pull/208/files#diff-880cf52daf5a2c4102cada8c839adb2a24cd310692aaf97106823f6fab984bf4
__init__.py https://github.com/crossplane/function-sdk-python/pull/208/files#diff-1ac881613eb12c4eaf758738a072c0e706eec445db169eb7265bd12f0c09a6c4
v1.py https://github.com/crossplane/function-sdk-python/pull/208/files#diff-2f803465ad37c7b2d7f754fb8ed20ee87f5031912dff3876eb1d8c72be03ddfd
__init__.py https://github.com/crossplane/function-sdk-python/pull/208/files#diff-7c37335647ada4e7f67bc28106f14e7dcb687c707db9c164825414b21a84e1dc
__init__.py https://github.com/crossplane/function-sdk-python/pull/208/files#diff-4fbdce767d4777e66d6b09ebf91f2e3694a53d8a5770b8586cb3f4b0d81acd0f
__init__.py https://github.com/crossplane/function-sdk-python/pull/208/files#diff-0935e902e3a63b3061cd557a46a9c505094c0f243e52b3336f045aabd8a903b1
__init__.py https://github.com/crossplane/function-sdk-python/pull/208/files#diff-d758b572097eb10a94c726f40478032a1e7606ce109578f41bb0e7204cc17b36
v1beta1.py https://github.com/crossplane/function-sdk-python/pull/208/files#diff-5966261d276f7babb6df9da65cfc8805886719a26a0e26259651920e8e1114bf
https://github.com/crossplane/function-sdk-python/blob/main/CODEOWNERS#L22
crossplane/function/resource.pyhttps://github.com/crossplane/function-sdk-python/pull/208/files#diff-05f183177eba52e1720d1fb16381620d80c3a5f071a87aa09b57177df0f33934
View file https://github.com/negz/function-sdk-python/blob/d18cbbb481bb9859b2f58625050d6482201cc021/crossplane/function/resource.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/crossplane/function-sdk-python/pull/208/{{ revealButtonHref }}
https://github.com/crossplane/function-sdk-python/pull/208/files#diff-05f183177eba52e1720d1fb16381620d80c3a5f071a87aa09b57177df0f33934
https://github.com/crossplane/function-sdk-python/pull/208/files#diff-05f183177eba52e1720d1fb16381620d80c3a5f071a87aa09b57177df0f33934
https://github.com/crossplane/function-sdk-python/pull/208/files#diff-05f183177eba52e1720d1fb16381620d80c3a5f071a87aa09b57177df0f33934
https://github.com/crossplane/function-sdk-python/blob/main/CODEOWNERS#L22
tests/test_resource.pyhttps://github.com/crossplane/function-sdk-python/pull/208/files#diff-cbf27c7a6a4139890bca166895b931c6ad62cff4f4c3bb341cc5eac6757a74b6
View file https://github.com/negz/function-sdk-python/blob/d18cbbb481bb9859b2f58625050d6482201cc021/tests/test_resource.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/crossplane/function-sdk-python/pull/208/{{ revealButtonHref }}
https://github.com/crossplane/function-sdk-python/pull/208/files#diff-cbf27c7a6a4139890bca166895b931c6ad62cff4f4c3bb341cc5eac6757a74b6
https://github.com/crossplane/function-sdk-python/pull/208/files#diff-cbf27c7a6a4139890bca166895b931c6ad62cff4f4c3bb341cc5eac6757a74b6
https://github.com/crossplane/function-sdk-python/pull/208/files#diff-cbf27c7a6a4139890bca166895b931c6ad62cff4f4c3bb341cc5eac6757a74b6
https://github.com/crossplane/function-sdk-python/pull/208/files#diff-cbf27c7a6a4139890bca166895b931c6ad62cff4f4c3bb341cc5eac6757a74b6
https://github.com/crossplane/function-sdk-python/pull/208/files#diff-cbf27c7a6a4139890bca166895b931c6ad62cff4f4c3bb341cc5eac6757a74b6
https://github.com/crossplane/function-sdk-python/pull/208/files#diff-cbf27c7a6a4139890bca166895b931c6ad62cff4f4c3bb341cc5eac6757a74b6
https://github.com/crossplane/function-sdk-python/pull/208/files#diff-cbf27c7a6a4139890bca166895b931c6ad62cff4f4c3bb341cc5eac6757a74b6
https://github.com/crossplane/function-sdk-python/pull/208/files#diff-cbf27c7a6a4139890bca166895b931c6ad62cff4f4c3bb341cc5eac6757a74b6
https://github.com/crossplane/function-sdk-python/blob/main/CODEOWNERS#L22
tests/testdata/models/io/k8s/api/__init__.pyhttps://github.com/crossplane/function-sdk-python/pull/208/files#diff-880cf52daf5a2c4102cada8c839adb2a24cd310692aaf97106823f6fab984bf4
View file https://github.com/negz/function-sdk-python/blob/d18cbbb481bb9859b2f58625050d6482201cc021/tests/testdata/models/io/k8s/api/__init__.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/crossplane/function-sdk-python/pull/208/{{ revealButtonHref }}
https://github.com/crossplane/function-sdk-python/blob/main/CODEOWNERS#L22
tests/testdata/models/io/k8s/api/resource/__init__.pyhttps://github.com/crossplane/function-sdk-python/pull/208/files#diff-1ac881613eb12c4eaf758738a072c0e706eec445db169eb7265bd12f0c09a6c4
View file https://github.com/negz/function-sdk-python/blob/d18cbbb481bb9859b2f58625050d6482201cc021/tests/testdata/models/io/k8s/api/resource/__init__.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/crossplane/function-sdk-python/pull/208/{{ revealButtonHref }}
https://github.com/crossplane/function-sdk-python/blob/main/CODEOWNERS#L22
tests/testdata/models/io/k8s/api/resource/v1.pyhttps://github.com/crossplane/function-sdk-python/pull/208/files#diff-2f803465ad37c7b2d7f754fb8ed20ee87f5031912dff3876eb1d8c72be03ddfd
View file https://github.com/negz/function-sdk-python/blob/d18cbbb481bb9859b2f58625050d6482201cc021/tests/testdata/models/io/k8s/api/resource/v1.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/crossplane/function-sdk-python/pull/208/{{ revealButtonHref }}
https://github.com/crossplane/function-sdk-python/blob/main/CODEOWNERS#L22
tests/testdata/models/io/upbound/m/__init__.pyhttps://github.com/crossplane/function-sdk-python/pull/208/files#diff-7c37335647ada4e7f67bc28106f14e7dcb687c707db9c164825414b21a84e1dc
View file https://github.com/negz/function-sdk-python/blob/d18cbbb481bb9859b2f58625050d6482201cc021/tests/testdata/models/io/upbound/m/__init__.py
Open in desktop https://desktop.github.com
https://github.com/crossplane/function-sdk-python/blob/main/CODEOWNERS#L22
tests/testdata/models/io/upbound/m/aws/__init__.pyhttps://github.com/crossplane/function-sdk-python/pull/208/files#diff-4fbdce767d4777e66d6b09ebf91f2e3694a53d8a5770b8586cb3f4b0d81acd0f
View file https://github.com/negz/function-sdk-python/blob/d18cbbb481bb9859b2f58625050d6482201cc021/tests/testdata/models/io/upbound/m/aws/__init__.py
Open in desktop https://desktop.github.com
https://github.com/crossplane/function-sdk-python/blob/main/CODEOWNERS#L22
tests/testdata/models/io/upbound/m/aws/iam/__init__.pyhttps://github.com/crossplane/function-sdk-python/pull/208/files#diff-0935e902e3a63b3061cd557a46a9c505094c0f243e52b3336f045aabd8a903b1
View file https://github.com/negz/function-sdk-python/blob/d18cbbb481bb9859b2f58625050d6482201cc021/tests/testdata/models/io/upbound/m/aws/iam/__init__.py
Open in desktop https://desktop.github.com
https://github.com/crossplane/function-sdk-python/blob/main/CODEOWNERS#L22
tests/testdata/models/io/upbound/m/aws/iam/accountalias/__init__.pyhttps://github.com/crossplane/function-sdk-python/pull/208/files#diff-d758b572097eb10a94c726f40478032a1e7606ce109578f41bb0e7204cc17b36
View file https://github.com/negz/function-sdk-python/blob/d18cbbb481bb9859b2f58625050d6482201cc021/tests/testdata/models/io/upbound/m/aws/iam/accountalias/__init__.py
Open in desktop https://desktop.github.com
Please reload this pagehttps://github.com/crossplane/function-sdk-python/pull/208/files
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.