# Buggy code
def Layout(self, request, response):
    """Render the toolbar."""
    self.ParseRequest(request)

    try:
        client_id = rdfvalue.RDFURN(self.aff4_path).Split(2)[0]
        update_flow_urn = flow.GRRFlow.StartFlow(
            client_id=client_id,
            flow_name="UpdateVFSFile",
            token=request.token,
            vfs_file_urn=rdfvalue.RDFURN(self.aff4_path),
            attribute=self.attribute_to_refresh,
        )

        update_flow = aff4.FACTORY.Open(
            update_flow_urn, aff4_type="UpdateVFSFile", token=request.token
        )
        self.flow_urn = str(update_flow.state.get_file_flow_urn)
    except IOError as e:
        raise IOError("Sorry. This path cannot be refreshed due to %s" % e)

    if self.flow_urn:
        response = super(UpdateAttribute, self).Layout(request, response)
        return self.CallJavascript(
            response,
            "UpdateAttribute.Layout",
            aff4_path=self.aff4_path,
            flow_urn=self.flow_urn,
            attribute_to_refresh=self.attribute_to_refresh,
            poll_time=self.poll_time,
        )


# Traceback (ArtifactNotRegisteredError)
Traceback (most recent call last): File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 644, in RunStateMethod responses=responses) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flows/general/discovery.py", line 153, in Platform next_state="ProcessKnowledgeBase") File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 784, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 940, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 927, in StartFlow flow_obj.Start() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 143, in Start first_flows = self.GetFirstFlowsForCollection() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 407, in GetFirstFlowsForCollection artifact_registry.REGISTRY.GetArtifact(artifact_name) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact_registry.py", line 304, in GetArtifact "directory." % name) ArtifactNotRegisteredError: Artifact WMIProfileUsersHomeDir missing from registry. You may need to sync the artifact repo by running make in the artifact directory.

# Fixed code
def Layout(self, request, response):
    """Render the toolbar."""
    self.ParseRequest(request)

    try:
        client_id = rdfvalue.RDFURN(self.aff4_path).Split(2)[0]
        update_flow_urn = flow.GRRFlow.StartFlow(
            client_id=client_id,
            flow_name="UpdateVFSFile",
            token=request.token,
            vfs_file_urn=rdfvalue.RDFURN(self.aff4_path),
            attribute=self.attribute_to_refresh,
        )

        update_flow = aff4.FACTORY.Open(
            update_flow_urn, aff4_type=aff4_grr.UpdateVFSFile, token=request.token
        )
        self.flow_urn = str(update_flow.state.get_file_flow_urn)
    except IOError as e:
        raise IOError("Sorry. This path cannot be refreshed due to %s" % e)

    if self.flow_urn:
        response = super(UpdateAttribute, self).Layout(request, response)
        return self.CallJavascript(
            response,
            "UpdateAttribute.Layout",
            aff4_path=self.aff4_path,
            flow_urn=self.flow_urn,
            attribute_to_refresh=self.attribute_to_refresh,
            poll_time=self.poll_time,
        )