Skip to content

Comments

feat: sync struct fields with upstream Casdoor and fix fmt.Errorf misuse#233

Open
prochac wants to merge 2 commits intocasdoor:masterfrom
prochac:master
Open

feat: sync struct fields with upstream Casdoor and fix fmt.Errorf misuse#233
prochac wants to merge 2 commits intocasdoor:masterfrom
prochac:master

Conversation

@prochac
Copy link

@prochac prochac commented Feb 17, 2026

Add new fields from upstream Casdoor to Application (Category, Type, Scopes, reverse proxy fields), Enforcer (ModelCfg), Group (ParentName, HaveChildren), Model (Description), Organization (AccountMenu, DcrPolicy), Provider (HttpHeaders, SslMode, EmailRegex, EnableProxy, EnablePkce), Record (Provider, Block), Session (ExclusiveSignin), Syncer (SSH/SSL fields), and Token (Resource).

Remove fields deleted upstream: ProviderItem.AlertType, Record.StatusCode/ExtendedUser, Syncer.TablePrimaryKey.

Replace fmt.Errorf with errors.New where no formatting is needed.

Fixes #232

Add new fields from upstream Casdoor to Application (Category, Type,
Scopes, reverse proxy fields), Enforcer (ModelCfg), Group (ParentName,
HaveChildren), Model (Description), Organization (AccountMenu,
DcrPolicy), Provider (HttpHeaders, SslMode, EmailRegex, EnableProxy,
EnablePkce), Record (Provider, Block), Session (ExclusiveSignin),
Syncer (SSH/SSL fields), and Token (Resource).

Remove fields deleted upstream: ProviderItem.AlertType,
Record.StatusCode/ExtendedUser, Syncer.TablePrimaryKey.

Replace fmt.Errorf with errors.New where no formatting is needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request synchronizes the Casdoor SDK struct definitions with the upstream Casdoor repository to address issue #232 regarding SDK being out of sync. The changes include adding new fields across multiple entities, removing deprecated fields, and correcting the misuse of fmt.Errorf where no formatting is needed.

Changes:

  • Added new fields to support upstream features including reverse proxy configuration (Application), SSH/SSL connection options (Syncer, Provider), resource indicators (Token), and various metadata fields across multiple entities
  • Removed deprecated fields that were deleted upstream (ProviderItem.AlertType, Record.StatusCode/ExtendedUser, Syncer.TablePrimaryKey)
  • Replaced fmt.Errorf with errors.New in util.go where no string formatting is performed

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
casdoorsdk/util.go Replaced fmt.Errorf with errors.New for error messages without formatting at lines 101 and 179
casdoorsdk/token.go Added Resource field for RFC 8707 Resource Indicator support
casdoorsdk/syncer.go Reorganized struct fields, added SSH/SSL configuration fields (SslMode, SshType, SshHost, SshPort, SshUser, SshPassword, Cert), removed TablePrimaryKey field
casdoorsdk/session.go Added ExclusiveSignin field for exclusive signin functionality
casdoorsdk/record.go Removed StatusCode and ExtendedUser fields, added Provider and Block fields, changed Object and Response to use mediumtext
casdoorsdk/provider.go Added HttpHeaders, SslMode, EmailRegex, EnableProxy, and EnablePkce fields with deprecation note for DisableSsl
casdoorsdk/organization.go Added AccountMenu and DcrPolicy fields
casdoorsdk/model.go Added Description field
casdoorsdk/group.go Added ParentName and HaveChildren fields for hierarchical group management
casdoorsdk/enforcer.go Added ModelCfg map field for model configuration
casdoorsdk/application.go Added Category, Type, and Scopes fields; added ScopeItem struct; added reverse proxy fields (Domain, OtherDomains, UpstreamHost, SslMode, SslCert); updated ProviderItem with CountryCodes and SignupGroup, removed AlertType

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


SessionId []string `json:"sessionId"`
SessionId []string `json:"sessionId"`
ExclusiveSignin bool `xorm:"-"`
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

The ExclusiveSignin field is missing a JSON struct tag. Based on the codebase convention where fields with xorm:"-" also include a json tag (see other examples in application.go, group.go, enforcer.go), this field should have json:"exclusiveSignin" added to maintain consistency with the API serialization.

Suggested change
ExclusiveSignin bool `xorm:"-"`
ExclusiveSignin bool `xorm:"-" json:"exclusiveSignin"`

Copilot uses AI. Check for mistakes.
GetX methods now pass through owner/name IDs as-is when the name
already contains a slash, instead of always prepending the client's
default organization. modifyX methods now only set Owner when the
caller left it empty, preserving explicitly set owners.

This allows callers (like Terraform providers) to operate on resources
in organizations other than the SDK client's configured default.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hsluoyz
Copy link
Member

hsluoyz commented Feb 17, 2026

@prochac you should not modify the Go struct content. just paste the struct without modification from Casdoor

@prochac
Copy link
Author

prochac commented Feb 17, 2026

@prochac you should not modify the Go struct content. just paste the struct without modification from Casdoor

You shouldn't leak the repository layer tags to SDK 😁

@hsluoyz
Copy link
Member

hsluoyz commented Feb 18, 2026

@prochac the current way makes the update more difficult in future. there will be unnescessary diff in git. copy-paste is simple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK is off-sync again

2 participants