Right way to stop export operator from saving with empty filename?
Check out the ImportHelper and ExportHelper code.
If you look at either the import or export operator templates in the text editor will see they use the helper mixin classes ImportHelper and ExportHelper
Here is the code for export helper from bpy_extras.io_utils  find it in the scripts/modules folder of your blender installation.
class ExportHelper:
    filepath: StringProperty(
        name=&quot;File Path&quot;,
        description=&quot;Filepath used for exporting the file&quot;,
        maxlen=1024,
        subtype='FILE_PATH',
    )
    check_existing: BoolProperty(
        name=&quot;Check Existing&quot;,
        description=&quot;Check and warn on overwriting existing files&quot;,
        default=True,
        options={'HIDDEN'},
    )

    # subclasses can override with decorator
    # True == use ext, False == no ext, None == do nothing.
    check_extension = True

    def invoke(self, context, _event):
        import os
        if not self.filepath:
            blend_filepath = context.blend_data.filepath
            if not blend_filepath:
                blend_filepath = &quot;untitled&quot;
            else:
                blend_filepath = os.path.splitext(blend_filepath)[0]

            self.filepath = blend_filepath + self.filename_ext

        context.window_manager.fileselect_add(self)
        return {'RUNNING_MODAL'}

    def check(self, _context):
        import os
        change_ext = False
        change_axis = _check_axis_conversion(self)

        check_extension = self.check_extension

        if check_extension is not None:
            filepath = self.filepath
            if os.path.basename(filepath):
                filepath = bpy.path.ensure_ext(
                    filepath,
                    self.filename_ext
                    if check_extension
                    else &quot;&quot;,
                )

                if filepath != self.filepath:
                    self.filepath = filepath
                    change_ext = True

        return (change_ext or change_axis)

which as you can see sets the name to &quot;untitled.&quot; if not set.
Check out the templates to see other properties that are used to extend this
# ExportHelper mixin class uses this
filename_ext = &quot;.txt&quot;

filter_glob: StringProperty(
    default=&quot;*.txt&quot;,
    options={'HIDDEN'},
    maxlen=255, 

Also a files collection bpy/file browser: get selected file names where directory is used to designate the folder the files reside in.
Set custom location for import/export helper