Has someone faced `'PrimitiveField' object has no ...
# general
l
Has someone faced
'PrimitiveField' object has no attribute 'filespec'
it looks like some of our plugins are breaking the pants intellij import
h
I haven't. I know what that literally means, but no idea the context and why IntelliJ cares about this Are you able to share more about the error message, like when it happens? And your plugins perhaps?
l
I can share the plugins code in a zip - Not ideal but that may help. This is happening when the intellij pants plugin is running the export function, I copied the exception from the logs:
Copy code
timestamp: 2021-01-06T15:50:51.374581
process title: pantsd [/Users/nicolasjoseph/code/datalogue/platform]
sys.argv: ['/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/bin/pants', '--pants-bin-name=/Users/nicolasjoseph/code/datalogue/platform/pants', '--pants-version=1.30.2', '--spec-file=/private/var/folders/m0/zfpk1rxn5h9grv0t6_pxsd8h0000gn/T/pants_target_specs7.in', '--no-quiet', '--export-available-target-types', 'export', '--output-file=/private/var/folders/m0/zfpk1rxn5h9grv0t6_pxsd8h0000gn/T/pants_depmap_run1012.out', '--formatted', '--export-libraries-sources', '--export-libraries-javadocs']
pid: 16299
Exception caught: (builtins.AttributeError)
  File "/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/lib/python3.7/site-packages/pants/bin/local_pants_runner.py", line 357, in run
    goal_runner_result = self._maybe_run_v1(v1)
  File "/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/lib/python3.7/site-packages/pants/bin/local_pants_runner.py", line 221, in _maybe_run_v1
    self.specs,
  File "/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/lib/python3.7/site-packages/pants/bin/goal_runner.py", line 224, in run
    return self._run_goals()
  File "/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/lib/python3.7/site-packages/pants/bin/goal_runner.py", line 195, in _run_goals
    result = self._execute_engine()
  File "/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/lib/python3.7/site-packages/pants/bin/goal_runner.py", line 183, in _execute_engine
    result = engine.execute(self._context, self._goals)
  File "/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/lib/python3.7/site-packages/pants/engine/legacy/round_engine.py", line 26, in execute
    self.attempt(context, goals)
  File "/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/lib/python3.7/site-packages/pants/engine/legacy/round_engine.py", line 233, in attempt
    goal_executor.attempt(explain)
  File "/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/lib/python3.7/site-packages/pants/engine/legacy/round_engine.py", line 278, in attempt
    task.execute()
  File "/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/lib/python3.7/site-packages/pants/task/console_task.py", line 77, in execute
    for value in self.console_output(targets) or tuple():
  File "/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/lib/python3.7/site-packages/pants/backend/project_info/tasks/export.py", line 469, in console_output
    graph_info = self.generate_targets_map(targets, classpath_products=classpath_products)
  File "/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/lib/python3.7/site-packages/pants/backend/project_info/tasks/export.py", line 311, in generate_targets_map
    process_target(target)
  File "/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/lib/python3.7/site-packages/pants/backend/project_info/tasks/export.py", line 230, in process_target
    info["globs"] = current_target.globs_relative_to_buildroot()
  File "/Users/nicolasjoseph/.cache/pants/setup/bootstrap-Darwin-x86_64/1.30.2_py37/lib/python3.7/site-packages/pants/build_graph/target.py", line 603, in globs_relative_to_buildroot
    return self._sources_field.filespec

Exception message: 'PrimitiveField' object has no attribute 'filespec'
h
Unclear if this is related, but
scalatest.py
line 120 is missing a comma to make it a tuple. It’s right now a single string
Everything else looks right..lmk if that makes a difference by chance
l
Looks like that's not it - I will let you know If I find more
thx for looking
h
What was the last version where this worked properly?
l
Not sure we just started using pants at 1.30
When I comment out all the plugins it is working properly. So there is definitely something wrong in the interaction between the 2
I also have been trying to pin-point it to one of the plugins in particular but it seems that it doesn't change anything
Actually was just able to pin-point to the docker plugin
Looks like culprit is the docker-node target we added
Solved it by changing this:
Copy code
class DockerNodeTarget(DockerBundleTarget):
  def __init__(self, sources=None, payload=None, **kwargs):
    payload = payload or Payload()
    payload.add_fields({
      'sources': PrimitiveField(list(sources or ()))
    })
    self.sources = sources
    super(DockerNodeTarget, self).__init__(payload=payload, **kwargs)
to this
Copy code
class DockerNodeTarget(DockerBundleTarget):
  def __init__(self, address=None, sources=None, payload=None, **kwargs):
    self.address = address
    payload = payload or Payload()
    payload.add_fields({
      'sources': self.create_sources_field(sources, address.spec_path, key_arg="sources"),
    })
    self.sources = sources
    super(DockerNodeTarget, self).__init__(address=address, payload=payload, **kwargs)
💯 1
h
Yay, glad you got that working. V1 is definitely tricker to get working imo