Fork me on GitHub
#biff
<
2023-06-13
>
Michael Hasse18:06:10

@foo Hi - I am working through the eelchat tutorial. In "Channels" the 2nd and 4th code block of chapter "Channels" there are references to existing code:

body]
     [:div {:class "grow-[2]"}]]))
but the actual existing code seems to be
body]
    [:.flex-grow]
    [:.flex-grow]]))

Jacob O'Bryant18:06:48

Thanks for the heads up; that must have slipped by. The two blocks are functionally equivalent in any case.

Jacob O'Bryant18:06:38

Just updated the tutorial.

Michael Hasse18:06:40

Great, thanks!

👌 2
Michael Hasse16:06:20

I had this working before, but at some point i started getting:

$ bb deploy

Rebuilding...

Done in 551ms.
ssh: connect to host  port 22: Network is unreachable
fatal: Could not read from remote repository.
In config.edn, I have :biff/base-url set to my custom domain. Is there another place where the domain is stored?

Jacob O'Bryant16:06:02

Check the :biff.tasks/server setting in config.edn. Looks like it's currently set to

Michael Hasse16:06:42

I forgot to mention that, it is also (already) correctly set to my custom domain.

Jacob O'Bryant16:06:43

hm, that's interesting

Jacob O'Bryant16:06:24

Could you paste the whole :tasks section of config.edn?

Jacob O'Bryant16:06:46

feel free to redact e.g. domain if you prefer

Jacob O'Bryant16:06:12

Also what's your biff version in tasks/deps.edn?

Michael Hasse16:06:28

:tasks {;; Set this if the auto-detection doesn't work
         ;; Possible values: macos-x64, macos-arm64, linux-x64, linux-arm64
         :biff.tasks/tailwind-build nil
         :biff.tasks/clj-args ["-J-XX:-OmitStackTraceInFastThrow"
                               "-J-XX:+CrashOnOutOfMemoryError"
                               "-J-Duser.timezone=UTC"
                               "-M" "-m" "com.eelchat"
                               "--port" "7888"
                               "--middleware" "[cider.nrepl/cider-middleware,refactor-nrepl.middleware/wrap-refactor]"]
         :biff.tasks/on-soft-deploy "\"(com.eelchat/on-save @com.eelchat/system)\""
         ;; Replace "master" with e.g. "main:master" or "dev:master" if you
         ;; want to deploy a different branch, for example:
         ;:biff.tasks/deploy-cmd ["git" "push" "prod" "main:master"]
         :biff.tasks/deploy-cmd ["git" "push" "prod" "master"]
         :biff.tasks/server ""}}

Jacob O'Bryant16:06:23

This is the implementation of bb deploy for current version of biff: https://github.com/jacobobryant/biff/blob/master/tasks/src/com/biffweb/tasks.clj#L192. If :biff.tasks/server is set correctly, I wonder if there's an issue with :biff.tasks/deploy-cmd or :biff.tasks/{deploy-to,deploy-from} . Actually since your error message includes the term "repository" it seems like it probably is an issue with the git command... That config section looks fine; I wonder if the url for the git remote is set to . Looking up the command to check that now...

Jacob O'Bryant16:06:51

does git remote show prod look correct? For one of my apps it looks like this:

$ git remote show prod
* remote prod
  Fetch URL: 
  Push  URL: 
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (fast-forwardable)

Jacob O'Bryant16:06:18

it should look the same for you, with being replaced by your domain

Jacob O'Bryant16:06:49

Actually git remote -v would be a better command to run

Jacob O'Bryant16:06:25

I get this:

$ git remote -v
origin  [email protected]:jacobobryant/yakread.git (fetch)
origin  [email protected]:jacobobryant/yakread.git (push)
prod     (fetch)
prod     (push)
If that's the problem, you can fix it with git remote set-url prod

Michael Hasse16:06:11

My bad, I must have copied

$ git remote add prod 
without changing the server name, and your solution worked. Thank you so much for your help!

Jacob O'Bryant16:06:19

No problem! It's an easy mistake to make 🙂

Michael Hasse17:06:40

I have a few more issues - is it o.k. to add them in this thread? Recaptcha fails after adding the keys to secrets.env

export POSTMARK_API_KEY=af1ee...
export RECAPTCHA_SECRET_KEY=LcDHJ...
$ bb logs
...
Jun 14 17:39:18 mhrdd-dev sh[3906]: [qtp2017659546-19] INFO com.biffweb.impl.middleware - 771ms 303 post /auth/send-link
Jun 14 17:39:18 mhrdd-dev sh[3906]: [qtp2017659546-23] INFO com.biffweb.impl.middleware -  13ms 200 get  /?error=recaptcha
Jun 14 17:41:08 mhrdd-dev sh[3906]: [qtp2017659546-18] INFO com.biffweb.impl.middleware -   0ms 405 post /
Jun 14 17:41:08 mhrdd-dev sh[3906]: [qtp2017659546-20] INFO com.biffweb.impl.middleware -   1ms 404 get  /.env
If I add the keys directly in config.edn (replacing the corresponding variables), everything seems to work, but I don't receive an email (I tried several emails and checked the spam folder).
$ bb logs
...
Jun 14 17:28:48 mhrdd-dev sh[3408]: [qtp1500545021-20] INFO com.biffweb.impl.middleware - 154ms 303 post /auth/send-link
Jun 14 17:28:48 mhrdd-dev sh[3408]: [qtp1500545021-16] INFO com.biffweb.impl.middleware -   8ms 200 get  /[email protected]

Jacob O'Bryant20:06:12

> I have a few more issues - is it o.k. to add them in this thread? Sure thing 🙂 After you update secrets.env, have you restarted the app (`bb restart`)? You'll need to do that for environment variables to take effect. Same for updating config.edn, though in that case a bb refresh also works and is a bit faster (i.e. restart the application code, but leave the JVM running). I would be surprised for adding the keys directly to config.edn to not trigger an error--biff will only use those keys as names of environment variables... actually I see that in that case, Biff will bypass the recaptcha check altogether (https://github.com/jacobobryant/biff/blob/master/src/com/biffweb/impl/auth.clj#L17). In any case, I would switch the values in config.edn back to be the environment variable names and try to fix the recaptcha error first, then we can see if email sending is still not working. For debugging recaptcha, you could make a dummy endpoint that does the recaptcha test, and see what parameters + output you're getting:

(defn debug-recaptcha [{:keys [biff/secret params]}]
  (prn (:g-recaptcha-response params))
  (prn (secret :recaptcha/secret-key))
  (prn (:body (http/post ""
                         {:form-params {:secret (secret :recaptcha/secret-key)
                                        :response (:g-recaptcha-response params)}
                          :as :json})))
  [:div "ok"])

(def plugin
  {:routes [["/debug-recaptcha" {:post debug-recaptcha}]
            ...]})
Then change the signup form's action from "/auth/send-link" to "/debug-recaptcha" (Be sure to redact the recaptcha secret key if you paste the result here)

Jacob O'Bryant20:06:21

For debugging the email sending, the auth plugin calls whatever function you have set at :biff/send-email (see https://github.com/jacobobryant/biff/blob/master/src/com/biffweb/impl/auth.clj#L65), which by default is in the email.clj file in your project: https://github.com/jacobobryant/biff/blob/master/example/src/com/example/email.clj#L82. So you can put some print statements in there to see what's going on.

Jacob O'Bryant20:06:14

The event log inside of Postmark/whatever email provider you're using is also handy for checking to see if an email got sent.

Jacob O'Bryant20:06:45

If the input parameters for the recaptcha http call look correct, it might be that you haven't added your domain to recaptcha's whitelist. You can go to the recaptcha admin console (https://www.google.com/recaptcha/admin) -> settings page to check that.

Michael Hasse16:06:20

I had this working before, but at some point i started getting:

$ bb deploy

Rebuilding...

Done in 551ms.
ssh: connect to host  port 22: Network is unreachable
fatal: Could not read from remote repository.
In config.edn, I have :biff/base-url set to my custom domain. Is there another place where the domain is stored?