Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix new labeler config steps #156

Merged
merged 6 commits into from
Aug 6, 2024
Merged

Conversation

foysalit
Copy link
Contributor

@foysalit foysalit commented Aug 2, 2024

This PR ensures that initial labeler set up steps can continue on without getting blocked by attempts to fetch server config.

Copy link

render bot commented Aug 2, 2024

@@ -241,6 +243,19 @@ function IdentityConfigurationFlow({
placeholder="Confirmation Code"
className="block w-full mt-2"
value={token}
autoFocus
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are unrelated UX improvements.

@foysalit foysalit requested a review from devinivy August 2, 2024 18:49
@@ -206,6 +207,7 @@ function Form(
const deactivatedAt = getDeactivatedAt(
repo ? { repo } : record ? { record } : {},
)
const canManageChat = checkPermission('canManageChat')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also unrelated but this hides the show messaging data block from UI for external labelers.

@@ -97,7 +97,7 @@ export const ModerationLabel = ({
const labelVal = toLabelVal(label, recordAuthorDid)
const isSelfLabeled = isSelfLabel(labelVal)
const labelDefFromService =
labelerServiceDef?.policies.definitionById[label.val]
labelerServiceDef?.policies.definitionById?.[label.val]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can crash a page if a plain label is added when the policy definition does not exist. So, this is more of a safety fallback.

Copy link
Collaborator

@devinivy devinivy Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type indicates that definitionById should be present— I think this points to an implementation issue around here:

const labelerDef = data.views[0] as ExtendedLabelerServiceDef
if (labelerDef?.policies.labelValueDefinitions) {
const definitionsById: Record<
string,
ComAtprotoLabelDefs.LabelValueDefinition
> = {}
labelerDef.policies.labelValueDefinitions.forEach((def) => {
definitionsById[def.identifier] = def
})
labelerDef.policies.definitionById = definitionsById
}

client.reconfigure({ skipRecord: skip })
client
.reconfigure({ skipRecord: skip })
.then(() => client.refetchServerConfig())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't expect the server config to be updated from the labeler record configuration flow—is it possible we don't need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't update but this is the issue i was seeing #156 (comment) so after the configuration is complete, we are fetching the server config for real here.

lib/client.ts Outdated
Comment on lines 82 to 87
// If the labeler needs further configuration, let's generate a mock serverConfig
// and let the user move forward with configuration steps
const needsConfiguration = config.needs.key || config.needs.service
const serverConfig = await (needsConfiguration
? parseServerConfig({})
: this._getServerConfig(agent, config.did))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand how this part works. Ideally IMO the server config and the labeler config could be managed independently from each other, and we wouldn't need to avoid loading the real server config. But maybe there's an overlap that I'm overlooking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requests to the server config seems to fail until the labeler config is available. the error was something like record not found or something along that line and since it doesn't make a lot of sense to fetch this until the labeler config is available, delaying the fetch makes sense to me.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of a reason that "record not found" would come from fetching the server config. I have a hunch that error may have been a red herring and we may not need this change, but I'm going to do some investigation to find out.

If we can avoid it I think that would be ideal, as it is a bit difficult to reason about when we're in the state of using a mock server config and what guarantees we leave that state. These configs seem independent to me at a glance, and we might be able to untangle them if they are indeed tangled. Taking a look!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(And if we're not sure whether we interpreted the "record not found" error properly, perhaps there's still an issue out there!)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhhhkay, I get what's going on now. They are tangled together a little bit because we need to use service proxying to fetch the server config. And server proxying is not going to work until the service is reflected in the labeler's DID document. So we need to wait until config.needs.service is false before we can make authed requests to ozone.

I made some small tweaks in fc7093c, let me know what you think!

Copy link
Collaborator

@devinivy devinivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! I tried this out, working well 👍

@foysalit foysalit merged commit 1c451e5 into main Aug 6, 2024
3 checks passed
@matthieusieben matthieusieben deleted the fix-new-labeler-config-steps branch November 15, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants