Coder Social home page Coder Social logo

Comments (6)

spunkedy avatar spunkedy commented on June 14, 2024

working on a PR now for this if this is a real issue

from livebook.

josevalim avatar josevalim commented on June 14, 2024

Yeah, a PR is welcome. We should probably return {:zta, module, info}.

from livebook.

josevalim avatar josevalim commented on June 14, 2024

And I was the one who broke it, here: c9d0c05 :)

from livebook.

spunkedy avatar spunkedy commented on June 14, 2024

haha no worries, I am trying to find the best way to add the test coverage now.

from livebook.

josevalim avatar josevalim commented on June 14, 2024

It is really hard because it happens on boot. A type system would have caught it. I think a unit test is fine for now.

from livebook.

spunkedy avatar spunkedy commented on June 14, 2024

Yeah, my plan was to allow for an override for the config function something like:

  def identity_provider!(env) do
    case get_system_env_or_test_provider(env) do
      nil ->
        {:session, LivebookWeb.SessionIdentity, :unused}

      "custom:" <> module_key ->
        destructure [module, key], String.split(module_key, ":", parts: 2)
        module = Module.concat([module])

        if Code.ensure_loaded?(module) do
          {:custom, module, key}
        else
          abort!("module given as custom identity provider in #{env} could not be found")
        end

      provider ->
        with [type, key] <- String.split(provider, ":", parts: 2),
             %{^type => module} <- identity_provider_type_to_module() do
          {nil, module, key}
        else
          _ -> abort!("invalid configuration for identity provider given in #{env}")
        end
    end
  end

  # Allow for this function to be tested more easily
  defp get_system_env_or_test_provider(env) do
    case {System.get_env(env), env} do
      {nil, "TEST_IDENTITY_" <> provider} -> provider
      {nil, _} -> nil
      {provider, _} -> provider
    end
  end

that would then allow us to check the contract, since the bug was in the application start of the pattern match

from livebook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.