Skip to content

Conversation

@san650
Copy link

@san650 san650 commented Dec 12, 2025

With elixir v1.9 there are warnings when updating structs using the struct name. e.g.

%User{user | name: "John Doe"} # deprecated in elixir v1.9

vs

%{user | name: "John Doe"}

This change is backward compatible with old elixir versions.

After

$ mix compile --force
Compiling 20 files (.ex)
Generated samly app

Before

$ mix compile --force

Compiling 20 files (.ex)
    warning: a struct for Samly.Assertion is expected on struct update:

        %Samly.Assertion{assertion | idp_id: idp_id}

    but got type:

        dynamic()

    where "assertion" was given the type:

        # type: dynamic()
        # from: lib/samly/sp_handler.ex:37:27
        {:ok, assertion} <- Samly.Helper.decode_idp_auth_resp(sp, saml_encoding, saml_response)

    when defining the variable "assertion", you must also pattern match on "%Samly.Assertion{}".

    hint: given pattern matching is enough to catch typing errors, you may optionally convert the struct update into a map update. For example, instead of:

        user = some_function()
        %User{user | name: "John Doe"}

    it is enough to write:

        %User{} = user = some_function()
        %{user | name: "John Doe"}

    typing violation found at:
    │
 39 │          assertion = %Assertion{assertion | idp_id: idp_id},
    │                      ~
    │
    └─ lib/samly/sp_handler.ex:39:22: Samly.SPHandler.consume_signin_response/1

     warning: a struct for Samly.IdpData is expected on struct update:

         %Samly.IdpData{idp_data | id: id, sp_id: sp_id, base_url: Map.get(opts_map, :base_url)}

     but got type:

         dynamic()

     where "idp_data" was given the type:

         # type: dynamic()
         # from: lib/samly/idp_data.ex:113:24
         idp_data

     when defining the variable "idp_data", you must also pattern match on "%Samly.IdpData{}".

     hint: given pattern matching is enough to catch typing errors, you may optionally convert the struct update into a map update. For example, instead of:

         user = some_function()
         %User{user | name: "John Doe"}

     it is enough to write:

         %User{} = user = some_function()
         %{user | name: "John Doe"}

     typing violation found at:
     │
 115 │     %IdpData{idp_data | id: id, sp_id: sp_id, base_url: Map.get(opts_map, :base_url)}
     │     ~
     │
     └─ lib/samly/idp_data.ex:115:5: Samly.IdpData.save_idp_config/2

     warning: a struct for Samly.IdpData is expected on struct update:

         %Samly.IdpData{idp_data | esaml_idp_rec: to_esaml_idp_metadata(idp_data, opts_map)}

     but got type:

         dynamic()

     where "idp_data" was given the type:

         # type: dynamic()
         # from: lib/samly/idp_data.ex:156:26
         idp_data

     when defining the variable "idp_data", you must also pattern match on "%Samly.IdpData{}".

     hint: given pattern matching is enough to catch typing errors, you may optionally convert the struct update into a map update. For example, instead of:

         user = some_function()
         %User{user | name: "John Doe"}

     it is enough to write:

         %User{} = user = some_function()
         %{user | name: "John Doe"}

     typing violation found at:
     │
 159 │         idp_data = %IdpData{idp_data | esaml_idp_rec: to_esaml_idp_metadata(idp_data, opts_map)}
     │                    ~
     │
     └─ lib/samly/idp_data.ex:159:20: Samly.IdpData.update_esaml_recs/3

     warning: a struct for Samly.IdpData is expected on struct update:

         %Samly.IdpData{
           idp_data
           | entity_id: get_entity_id(md_xml),
             signed_requests: get_req_signed(md_xml),
             certs: signing_certs,
             fingerprints: idp_cert_fingerprints(signing_certs),
             sso_redirect_url: get_sso_redirect_url(md_xml),
             sso_post_url: get_sso_post_url(md_xml),
             slo_redirect_url: get_slo_redirect_url(md_xml),
             slo_post_url: get_slo_post_url(md_xml),
             nameid_format: get_nameid_format(md_xml)
         }

     but got type:

         dynamic()

     where "idp_data" was given the type:

         # type: dynamic()
         # from: lib/samly/idp_data.ex:263:31
         idp_data

     when defining the variable "idp_data", you must also pattern match on "%Samly.IdpData{}".

     hint: given pattern matching is enough to catch typing errors, you may optionally convert the struct update into a map update. For example, instead of:

         user = some_function()
         %User{user | name: "John Doe"}

     it is enough to write:

         %User{} = user = some_function()
         %{user | name: "John Doe"}

     typing violation found at:
     │
 274 │     %IdpData{
     │     ~
     │
     └─ lib/samly/idp_data.ex:274:5: Samly.IdpData.from_xml/2

Generated samly app

@san650
Copy link
Author

san650 commented Dec 12, 2025

@k-cross do you know if this project is still being maintained? I saw that you merged the lasts few PRs.

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.

1 participant