Fork me on GitHub
#polylith
<
2023-07-13
>
Stuart Nath18:07:37

Hello Everyone, I've been using Polylith. I have 4 components (and it was working). I must have done something when working, because I tried to create a new component and got the error below. I ran poly/info and get the same error. A colleague tried to do the same thing on his machine and got the same error, so it seems to be specific to this Polylith code base and not the poly tool. Can any of you point me to where I can fix this?

C:\Users\XX\XXX\XXXX> poly info
#error {
 :cause Cannot invoke "Object.toString()" because "s" is null
 :via
 [{:type java.lang.NullPointerException
   :message Cannot invoke "Object.toString()" because "s" is null
   :at [clojure.string$starts_with_QMARK_ invokeStatic string.clj 365]}]
 :trace
 [[clojure.string$starts_with_QMARK_ invokeStatic string.clj 365]
  [polylith.clj.core.workspace.lib_imports$library_QMARK_ invokeStatic lib_imports.clj 5]
  [polylith.clj.core.workspace.lib_imports$lib_imports_source$fn__7435 invoke lib_imports.clj 15]
  [clojure.core$filter$fn__5962 invoke core.clj 2838]
  [clojure.lang.LazySeq sval LazySeq.java 42]
  [clojure.lang.LazySeq seq LazySeq.java 51]
  [clojure.lang.RT seq RT.java 535]
  [clojure.core$seq__5467 invokeStatic core.clj 139]
  [clojure.core$sort invokeStatic core.clj 3114]
  [clojure.core$sort invokeStatic core.clj 3103]
  [polylith.clj.core.workspace.lib_imports$lib_imports_source invokeStatic lib_imports.clj 16]
  [polylith.clj.core.workspace.lib_imports$lib_imports invokeStatic lib_imports.clj 18]
  [polylith.clj.core.workspace.component$enrich invokeStatic component.clj 6]
  [polylith.clj.core.workspace.core$enrich_workspace$fn__7526 invoke core.clj 34]
  [clojure.core$mapv$fn__8535 invoke core.clj 6979]
  [clojure.lang.PersistentVector reduce PersistentVector.java 343]
  [clojure.core$reduce invokeStatic core.clj 6885]
  [clojure.core$mapv invokeStatic core.clj 6970]
  [polylith.clj.core.workspace.core$enrich_workspace invokeStatic core.clj 33]
  [polylith.clj.core.workspace.interface$enrich_workspace invokeStatic interface.clj 6]
  [polylith.clj.core.command.core$read_workspace invokeStatic core.clj 53]
  [polylith.clj.core.command.core$workspace_reader_fn$fn__27093 invoke core.clj 60]
  [polylith.clj.core.command.core$execute invokeStatic core.clj 67]
  [polylith.clj.core.command.interface$execute_command invokeStatic interface.clj 4]
  [polylith.clj.core.poly_cli.core$_main invokeStatic core.clj 31]
  [polylith.clj.core.poly_cli.core$_main doInvoke core.clj 7]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [polylith.clj.core.poly_cli.core main nil -1]]}

2
Rowan Chase00:07:54

@snath I was banging up against this same NPE yesterday, in my case this change fixed it:

tengstrand06:07:32

Will have a look.

tengstrand12:07:49

The code works when there is no $ sign:

(->> "io.opentracing.Tracer"
     (re-find #"(.*)\.\w+$")
     last)
But returns nil if it is:
(->> "io.opentracing.Tracer$SpanBuilder"
     (re-find #"(.*)\.\w+$")
     last)
I can problably fix this myself, but doesn't have time today, and I'm not good enough to fix it straight away, so please help out if someone knows how to change the regex! The code should return "io.opentracing" in both cases.

Stuart Nath13:07:55

@U059WLVKGHW @U1G0HH87L This error makes sense, because this issue occurred after we added this java dependency: (:import com.github.servicenow.ds.stats.stl.SeasonalTrendLoess$Builder) Which has "$" in it. If anyone has a work-around, I'd appreciate it! In the meantime, I'll be on the lookout for the regex fix. Thank you both for your quick and prompt help.

tengstrand15:07:27

You can put parenthesis around it maybe, see Rowan’s screenshot above.

Stuart Nath17:07:23

This was the fix. Thank you!

👍 4
Kent Bull21:07:38

Curious, what does the “$” do in an import? Is it only for accessing https://stackoverflow.com/questions/25104301/dollar-sign-in-clojure-symbol-name as this SO post sais?

tengstrand19:07:42

Yes, nested classes. I changed the regex to (.*)\.[a-zA-Z0-9_$]+$ and now it seems to work. Will put a notice here when https://github.com/polyfy/polylith/issues/313 is merged to master.

tengstrand19:08:52

This was merged to master a while ago @U02SLLZ1STE.

2
tengstrand19:07:32

What version of the poly tool are you using? Do you get the same error if you use the latest commit in the main branch (`1209a81e6b8f70987050d65d106e99d1a902969a`)? The way the poly tool parses files and the error handling has been improved quite a lot since 0.2.17-alpha was released.

Stuart Nath20:07:48

I am using the same commit you listed above - 1209a81e6b8f70987050d65d106e99d1a902969a

tengstrand20:07:15

Okay. Do you think you can narrow down the problem, e.g. by going back one commit at a time till you see in which commit the problem was introduced, and then try to see which clj or edn file that introduced it? It could be a bug in the poly tool, so I need to be able to reproduce it.

seancorfield20:07:09

@snath I would suggest checking the syntax of your various deps.edn files -- based on that exception, I suspect you have something malformed in a dependency that is causing poly to fail when trying to analyze the dependencies across components. Is this repo public, where we can take a look?

Stuart Nath22:07:50

@seancorfield Thank you for that guidance. I'm going through the deps.edn's. Unfortunately its not a public repo, so I can't share it.

tengstrand05:07:58

Let's continue the discussion here, so that we don't keep "spamming" the main feed (my mistake)!